Lisp to define Dimension Style?

Discussion in 'AutoCAD' started by Pamulli, Feb 15, 2005.

  1. Pamulli

    Pamulli Guest

    I am brand new to creating lisps and would like to know the syntax for creating a lisp to define a dimension style. I'd like to create a function that can be called up within AutoCAD to define a particular dimension style. I've been able to find some posts describing some of the dimension variables, but I don't know the syntax to place this into a lisp.

    Thanks,
    Paul Mullis
     
    Pamulli, Feb 15, 2005
    #1
  2. A script works well for me. Type " dimstyle " and view the text sceen
    for all the variable override settings. I copy/pasted these settings to
    a script file and run the script to reset the dimstyle if something
    changes it. It could also be adapted to invoke different dimstyles with
    different scripts to set a particular dimstyle on the run.
     
    Harold Leveritt, Feb 15, 2005
    #2
  3. Pamulli

    Rudy Tovar Guest

    oNe mORe ThInG to cOnsiDer, iS That if yOU Do cReaTe a fUncTIon tO deFiNE a
    diMenSIon sTYle, uSE aCTiveX

    dON't usE eNTmaKe beCAusE CerTAin dxF coDEs wiLl anD aRe bEiNg ellImiNAted,
    ANd caN OnLy bE acCEsseD by aCTiveX.

    yOU knoW I'm GetTinG a LitTle DizZy...
     
    Rudy Tovar, Feb 15, 2005
    #3
  4. :) Slow day Rudy?
     
    John Michalik, Feb 15, 2005
    #4
  5. Pamulli

    Pamulli Guest

    Thank for the tips. Can anyone post a sample code that shows how this is done in active x? Even if it only sets one variable and then saves the style. I'm not at all familiar with Active X, and any help would be greatly appreciated.
     
    Pamulli, Feb 15, 2005
    #5
  6. Pamulli

    Rudy Tovar Guest

    i'M FEelinG a liTtle liGHtheaDed...

     
    Rudy Tovar, Feb 15, 2005
    #6
  7. Pamulli

    Jeff Mishler Guest

    Here's a quick example:

    (setq *doc* (vla-get-activedocument (vlax-get-acad-object)));get the drawing
    (setq dims (vla-get-dimstyles *doc*));get the dimstyles collection
    (setq dim (vla-add dims "MyNewStyle"));add a new dimstyle
    (vlax-invoke *doc* 'setvariable "dimscale" 48.0);apply override to current
    dimstyle
    ;;make any other varaible changes here
    (vla-copyfrom dim *doc*);place the new override(s) to our new dimstyle
     
    Jeff Mishler, Feb 15, 2005
    #7
  8. Pamulli

    ECCAD Guest

    Time to vacuum the Keyboard ?
     
    ECCAD, Feb 15, 2005
    #8
  9. Pamulli

    Pamulli Guest

    Thanks for the sample code, I'd also like to know how I can call the active-x as a command? I'm trying to get it so that I can create a command for each dimension style and if my users are in a 1/4" drawing they call the appropriate command and it loads or resets the correct dimension style. I understand how to define a function with visual lisp, but how do I do it with active-x?

    Thanks,
    Paul
     
    Pamulli, Feb 15, 2005
    #9
  10. ;***** wskaznik aplikacji *****
    (defun vla-AcadObject ()
    (cond
    (ACADOBJECT)
    (T (setq ACADOBJECT (vlax-Get-Acad-Object)))
    )
    );end vla-AcadObject
    ;*************************

    ;***** wskaznik dokumentu *****
    (defun vla-ActiveDocument ()
    (cond
    (ACTIVEDOCUMENT)
    (T (setq ACTIVEDOCUMENT
    (vla-Get-ActiveDocument (vla-AcadObject))
    )
    )
    )
    );end vla-ActiveDocument
    ;****************************

    ;***** lista styli wymiarowych *****
    (defun vla-list-DimStyles (/ OUT)
    (vlax-for ITEM
    (vla-get-DimStyles (vla-ActiveDocument))
    (setq OUT (cons (vla-get-Name ITEM) OUT))
    )
    (if OUT (mapcar 'strcase (reverse OUT)))
    );defun vla-list-DimStyles
    ;*****************************

    ;***** obiekt wymiarowy vla okreslony przez nazwê *****
    (defun vla-get-DimStyle (NAME / ITEM)
    (if (setq ITEM
    (vl-position (strcase NAME) (vla-list-DimStyles))
    )
    (vla-Item (vla-get-DimStyles (vla-ActiveDocument)) ITEM)
    )
    );end vla-get-DimStyle
    ;**********************************************

    ;***** ustawienie zmiennych *****
    (defun SetVarDim (VARDIMLIST)
    (foreach ITEM VARDIMLIST
    (setvar (car ITEM) (cadr ITEM))
    )
    );end SetVarDim
    ;***************************

    (setq ACADOBJECT nil
    ACTIVEDOCUMENT nil)
    ;***** funkcja definiujaca nowy styl *****
    (defun vla-AddDimStyle (NAME SETLIST CURRENT / ALL-DIMS DIM TMPLIST)
    (foreach ITEM SETLIST
    (setq TMPLIST
    (append TMPLIST
    (list (list (car ITEM) (getvar (car ITEM))))
    )
    )
    )
    (cond
    ((not (tblsearch "dimstyle" NAME))
    (setq ALL-DIMS (vla-get-DimStyles (vla-ActiveDocument))
    DIM (vla-Add ALL-DIMS NAME)
    )
    )
    (T (setq DIM (vla-get-DimStyle NAME))
    )
    )
    (SetVarDim SETLIST)
    (vlax-Invoke-Method DIM 'CopyFrom (vla-ActiveDocument))
    (if CURRENT
    (vla-put-ActiveDimStyle
    (vla-ActiveDocument)
    DIM
    )
    (SetVarDim TMPLIST)
    )
    )
    ;********************************

    for example:
    (vla-AddDimStyle "Test" '(("DIMTSZ" 0.14) ("DIMTXT" 0.25) ("DIMTVP" 0.1)
    ("DIMEXE" 0.1) ("DIMDLE" 0.1) ("DIMEXO" 0.3) ("DIMZIN" 0) ("DIMCLRD" 5)
    ("DIMCLRE" 5) ("DIMCLRT" 4) ("DIMTMOVE" 2) ("DIMUNIT" 2) ("DIMAUNIT" 2)
    ("DIMDEC" 2) ("DIMADEC" 4)))

    best regards from Poland
     
    User of Internet, Feb 16, 2005
    #10
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.