+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Senior Member
    Computer Details
    nicolas's Computer Details
    Operating System:
    Windows 7
    Computer:
    Intel Dual Core 64 Bits
    RAM:
    2 GB
    Using
    AutoCAD 2012
    Join Date
    Jan 2008
    Location
    Port Louis, Republic of Mauritius
    Posts
    332

    Default Lisp to Change to all Dimension Styles in one go and accross multiple files

    Registered forum members do not see this ad.

    Hi,

    I am looking for a lisp code that can execute 3 changes to variable in all the dimension styles namely:

    1. Dimension Lines - Color set to 52
    2. Extension Lines - Color set to 52
    3. Text Appearance - Color set to 52

    To push thing further, I also need to execute this lisp to all drawings in a specific folder.

    Can anybody help me on this?

    Thanks in advance.

    Regards,

    Nicolas

  2. #2
    Senior Member
    Computer Details
    nicolas's Computer Details
    Operating System:
    Windows 7
    Computer:
    Intel Dual Core 64 Bits
    RAM:
    2 GB
    Using
    AutoCAD 2012
    Join Date
    Jan 2008
    Location
    Port Louis, Republic of Mauritius
    Posts
    332

    Default

    Here is a Lee Mac's code that I modified slightly to meet my needs:

    Code:
    (defun c:tnm (/ dimlst doc ss)
      (vl-load-com)
    
      (setq dimlst '("1" "2" "3")) ;; Change as necessary
      
      (vlax-for dim (vla-get-Dimstyles
                      (setq doc
                        (vla-get-ActiveDocument
                          (vlax-get-acad-object))))
        (if (vl-position (vla-get-Name dim) dimlst)
          (progn
            (vla-put-activeDimstyle doc dim)
            (setvar "DIMCLRE" 52)
            (setvar "DIMCLRD" 52)
        (setvar "DIMCLRT" 52)
            (vla-copyfrom dim doc))))
    
      (if (setq ss (ssget "_X" '((0 . "DIMENSION"))))
        (mapcar 'vla-update
          (mapcar 'vlax-ename->vla-object
            (mapcar 'cadr (ssnamex ss)))))
      
      (princ))
    There is a line that I want to change namely:

    Code:
     (setq dimlst '("1" "2" "3")) ;; Change as necessary
    It would be great if the application can list all the dimension styles automatically and save it to the variable dimlst.

  3. #3
    Forum Deity Dadgad's Avatar
    Using
    AutoCAD 2012
    Join Date
    Nov 2011
    Location
    At the confluence of worthlessness & invaluability
    Posts
    3,137

    Default

    This is not lisp, and no way that it will work as well as Lee's lisp,

    but you can get pretty close to what you are after by configuring the STANDARDS options
    and using a .dws file, while batch checking.
    Attached Images
    Volume and repetition do not validate opinions forged in the absence of thought.

  4. #4
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,633

    Default

    Check this out

    Code:
    (defun c:Test (/ d dim ss i obj)
      (vl-load-com)
      (cond ((not acdoc)
             (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
            )
      )
      (while (setq d (tblnext "DIMSTYLE" (null d)))
        (setq dim (vla-item (vla-get-Dimstyles
                              acdoc
                            )
                            (cdr (assoc 2 d))
                  )
        )
        (vla-put-activeDimstyle acdoc dim)
        (setvar "DIMCLRE" 52)
        (setvar "DIMCLRD" 52)
        (setvar "DIMCLRT" 52)
        (vla-copyfrom dim acdoc)
      )
      (if (setq ss (ssget "_X" '((0 . "DIMENSION"))))
        (repeat (setq i (sslength ss))
          (setq obj (ssname ss (setq i (1- i))))
          (vla-update (vlax-ename->vla-object obj))
        )
      )
      (princ)
    )
    Last edited by Tharwat; 12th May 2012 at 11:37 am. Reason: Another and better way of coding
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,744

    Default

    Hi nicolas,

    That is some very old code of mine that you have discovered!

    Here is how I might rewrite the function today:

    Code:
    (defun c:dimupd ( / adm doc sel styles )
    
        (setq styles '("1" "2" "3") ;; Dimension Styles to Update
              styles  (mapcar 'strcase styles)
        )
        (setq doc (vla-get-activedocument (vlax-get-acad-object))
              adm (vla-get-activedimstyle doc)
        )
        (vlax-for dim (vla-get-dimstyles doc)
            (if (member (strcase (vla-get-name dim)) styles)
                (progn
                    (vla-put-activedimstyle doc dim)
                    (setvar 'dimclre 52)
                    (setvar 'dimclrd 52)
                    (setvar 'dimclrt 52)
                    (vla-copyfrom dim doc)
                )
            )
        )
        (if (ssget "_X" '((0 . "*DIMENSION")))
            (progn
                (vlax-for obj (setq sel (vla-get-activeselectionset doc))
                    (vl-catch-all-apply 'vla-update (list obj))
                )
                (vla-delete sel)
            )
        )
        (vla-put-activedimstyle doc adm)
        (princ)
    )
    (vl-load-com) (princ)
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  6. #6
    Senior Member
    Computer Details
    nicolas's Computer Details
    Operating System:
    Windows 7
    Computer:
    Intel Dual Core 64 Bits
    RAM:
    2 GB
    Using
    AutoCAD 2012
    Join Date
    Jan 2008
    Location
    Port Louis, Republic of Mauritius
    Posts
    332

    Default

    Thanks Lee Mac, Tharwat and Dadgad for the codes. Tharwat's code is working just fine. It applies the changes automatically to all the dimension styles irrespective of the names. Is there a way to incorporate that feature of Tharwat's code in Lee Mac's updated codes? Is there a way to automatically carry the instructions in this code to all drawings in a specific folder like in Lee Mac's Bfind lisp without using a script program like Script Pro? Or is there a program that can do even more than that in a library somewhere with DCL feature incorporated?

  7. #7
    Senior Member
    Computer Details
    nicolas's Computer Details
    Operating System:
    Windows 7
    Computer:
    Intel Dual Core 64 Bits
    RAM:
    2 GB
    Using
    AutoCAD 2012
    Join Date
    Jan 2008
    Location
    Port Louis, Republic of Mauritius
    Posts
    332

    Default

    Thanks DADGAD for the standard feature. I have read about it years ago and never really try it. I will do my best to learn of this feature as I believe it will be of great help to me.

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,744

    Default

    Oh, I thought you wanted to only modify certain styles, modifying all styles simplifies the code even more so:

    Code:
    (defun c:dimupd ( / adm doc sel )
        (setq doc (vla-get-activedocument (vlax-get-acad-object))
              adm (vla-get-activedimstyle doc)
        )
        (vlax-for dim (vla-get-dimstyles doc)
            (vla-put-activedimstyle doc dim)
            (setvar 'dimclre 52)
            (setvar 'dimclrd 52)
            (setvar 'dimclrt 52)
            (vla-copyfrom dim doc)
        )
        (if (ssget "_X" '((0 . "*DIMENSION")))
            (progn
                (vlax-for obj (setq sel (vla-get-activeselectionset doc))
                    (vl-catch-all-apply 'vla-update (list obj))
                )
                (vla-delete sel)
            )
        )
        (vla-put-activedimstyle doc adm)
        (princ)
    )
    (vl-load-com) (princ)
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  9. #9
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,633

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by nicolas View Post
    Tharwat's code is working just fine. It applies the changes automatically to all the dimension styles irrespective of the names.
    Is there a way to automatically carry the instructions in this code to all drawings in a specific folder .....
    You're welcome , and happy to have my code working for you .

    As a manipulation on the solution on the issue , try the following code from my routine and add it to your acaddoc.lsp or use command "appload" and add the code to Contents (briefcase ) to be able to run the code automatically on all new opening drawings. And after that open all your needed drawings and the code would do the trick , save and close each one a lone .

    Code:
      (vl-load-com)
      (cond ((not acdoc)
             (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
            )
      )
      (while (setq d (tblnext "DIMSTYLE" (null d)))
        (setq dim (vla-item (vla-get-Dimstyles
                              acdoc
                            )
                            (cdr (assoc 2 d))
                  )
        )
        (vla-put-activeDimstyle acdoc dim)
        (setvar "DIMCLRE" 52)
        (setvar "DIMCLRD" 52)
        (setvar "DIMCLRT" 52)
        (vla-copyfrom dim acdoc)
      )
      (if (setq ss (ssget "_X" '((0 . "DIMENSION"))))
        (repeat (setq i (sslength ss))
          (setq obj (ssname ss (setq i (1- i))))
          (vla-update (vlax-ename->vla-object obj))
        )
      )
      (princ)
    (command "_.qsave")
    (command "_.close")
    When you finish detach the code from Autocad to avoid implementing the code on all new opening drawings .
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

Similar Threads

  1. ATTIN accross multiple tabs?
    By Small Fish in forum AutoCAD General
    Replies: 0
    Last Post: 11th Nov 2009, 04:37 am
  2. Dimension Styles
    By rwhitt0724 in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 14th Oct 2009, 07:32 pm
  3. VBA - Dimension Styles
    By wannabe in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 21st Oct 2008, 06:18 pm
  4. Dimension Styles
    By rush02112 in forum Autodesk Inventor
    Replies: 2
    Last Post: 16th Jun 2007, 10:25 pm
  5. Dimension Styles
    By JaketheMan in forum AutoCAD General
    Replies: 1
    Last Post: 15th May 2007, 11:43 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts