Loading Multiline styles via LISP

Discussion in 'AutoCAD' started by W. Morris, Jul 9, 2003.

  1. W. Morris

    W. Morris Guest

    Hello,

    I've found this question asked often online but never really answered:
    Is there a method of loading a set of defined multilines via lisp or
    another method? Loading manualy using the mlstyle dialog box isn't
    practical. These new styles will be used in lots of older drawings
    wherein they are not defined.

    Thanks,

    Wayne
     
    W. Morris, Jul 9, 2003
    #1
  2. W. Morris

    DonB Guest

    I just insert a template drawing that has all my multiline styles defined.

    This will show what's currently defined so you can check first to see if
    it's already there.

    (defun mlstyles ()
    (mapcar 'strcase
    (mapcar 'cdr
    (vl-remove-if-not
    '(lambda (x) (= (car x) 3))
    (dictsearch (namedobjdict) "ACAD_MLINESTYLE")
    )
    )
    )
    )

    Just make sure the template drawing is saved as an earlier release to be
    compatible.

    Don
     
    DonB, Jul 10, 2003
    #2
  3. W. Morris

    David Kozina Guest

    In order of elegance - least to more:

    1) Define all the styles you'll ever use in your template dwt file.
    Benefit: They'll be there when you need them.
    Detriment: They'll be there when you DON'T need them (drawing BLOAT).
    Worse, they'll be there when you REALLY DON'T want them.

    2) If you block insert drawing(s) containing one or more defined mlinestyles
    they'll be defined in the new drawing.
    Benefit: Probably the easiest way around the dialog box
    programatically. (Quickest solution)
    Detriment: Klunky solution. Generally leads to either lots of block
    files to maintain or, if more mlinestyles are defined per block, we're back
    to BLOAT again.

    3) Check out the dxf-style coding in some of your .mln files (readable in a
    text editor), and, in conjunction with the .dxf group code documentation in
    the HELP files, figure out how a mlinestyle is actually defined. Then you
    could create your own "mlinestyle definition" file, in the form of a nested
    association list, perhaps, that could be used to create the mlinestyles
    programatically, on the fly, on an as-needed basis. I don't know what
    higher level vlisp functions could be used for this, but the core AutoLISP
    functions in R14 were sufficient for this task. And it has continued to
    work well for us to the present day.
    Benefit: One reasonably small editable definition file (association
    list) can likely handle all your styles and more styles can be added to as
    the need dictates. Fast. No mlinestyle dialog box - ever again. I can't
    even remember the last time I saw that thing.
    Detriment: Homework and "some assembly" required.
    (Uphill solution, but the payback is grand)

    4) MOST ELEGANT method? (Likely far beyond my current programming
    abilities.)


    Here is a link to some code that may be of some help, should you choose
    what's behind Door #3:

    http://xarch.tu-graz.ac.at/autocad/stdlib/ENTMAKE.LSP

    A function using said association definition list to ENTMAKE an MLINESTYLE
    can be found near the end of the file.

    Additional information may be found here:

    http://xarch.tu-graz.ac.at/autocad/stdlib/docs/STDLIB.HLP

    hth,
    David Kozina
     
    David Kozina, Jul 10, 2003
    #3
  4. W. Morris

    R. Togores Guest

    Here is my posting from the "entmake & ltype" thread (2003-05-19 ) about
    entmake-ing linetypes:
    You can search for this thread in Google Groups.

    Hope it helps.

    Autor:R. Togores ()
    Asunto:Re: entmake & ltype
    View: Complete Thread (6 artículos)
    Original Format
    Grupos de noticias:autodesk.autocad.customization
    Fecha:2003-05-19 05:12:52 PST

    This routine from our book "Programacion en AutoCAD co Visual LISP"
    will entmake a simple linetype (no text or forms):

    ;;;Listado 10.38. Función que crea un nuevo tipo de línea en el
    dibujo.
    (defun ent-tipolinea
    (nombre descripcion lista-parametros)
    (entmake
    (append
    (list
    '(0 . "LTYPE")
    '(100 . "AcDbSymbolTableRecord")
    '(100 . "AcDbLinetypeTableRecord")
    (cons 2 nombre)
    '(70 . 0)
    (cons 3 descripcion)
    (cons 72 (ascii (nth 0 lista-parametros)))
    (cons 73 (- (length lista-parametros) 1))
    (cons
    40
    (apply '+
    (mapcar 'abs (cdr lista-parametros)))))
    (apply 'append
    (mapcar
    '(lambda (x) (list (cons 49 x) '(74 . 0)))
    (cdr lista-parametros))))))

    It works like this:

    (ENT-TIPOLINEA
    "SOS" "A personal line" '("A" 12 -3 12 -3 12 -3 0 -3 0 -3 0 -3))

    For more information on the book:
    http://grupos.unican.es/egicad/vlisp/
    or
    http://personales.unican.es/togoresr/

    The book is in spanish... yet.

    Regards,
    Reinaldo
     
    R. Togores, Jul 10, 2003
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.