Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need code to modify all dimstyles

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
301 Views, 9 Replies

Need code to modify all dimstyles

My architects want all the dimension styles to be a thin dimension line and
thick text.
I can modify my dimstyle to do that but what I need to do is to modify
either the
dimension text color or the dimension lines in every dimension in a drawing.
I'd like to update every dimstyle defined in a drawing.

How can I do that?

--
Dave
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

Hi David,

I use code similar to that below to globally change the "dimscale" for all
dimstyles.
The sample below is modified to change the text color instead.

Hope it helps.

Gary

[Code]
;Globally change text color for all existing dimstyles.

(defun C:DCOL (/ cursty intnum tblmem stynme oldech)

(setq oldech (getvar "cmdecho"))
(setvar "cmdecho" 0)

(setq cursty (getvar "dimstyle"))
(setq intnum (getint "\nEnter new dimension text color: "))

(setvar "dimclrt" intnum)

(setq tblmem (tblnext "dimstyle" 1))
(while (/= nil tblmem)
(setq stynme (cdr (assoc 2 tblmem)))
(command "-dimstyle" "restore" stynme)
(setvar "dimclrt" intnum)
(command "-dimstyle" "save" stynme "yes")
(setq tblmem (tblnext "dimstyle"))
);end while

(command "dimstyle" "restore" cursty)
(setvar "cmdecho" oldech)

(princ "Dimension color set to ") (princ intnum) (princ " for all styles.")
(princ)

);end function DCOL
[/Code]
Message 3 of 10
Anonymous
in reply to: Anonymous

thankx Gary that did the trick

--
Dave

"Gary McMaster" wrote in message
news:5160644@discussion.autodesk.com...
Hi David,

I use code similar to that below to globally change the "dimscale" for all
dimstyles.
The sample below is modified to change the text color instead.

Hope it helps.

Gary

[Code]
;Globally change text color for all existing dimstyles.

(defun C:DCOL (/ cursty intnum tblmem stynme oldech)

(setq oldech (getvar "cmdecho"))
(setvar "cmdecho" 0)

(setq cursty (getvar "dimstyle"))
(setq intnum (getint "\nEnter new dimension text color: "))

(setvar "dimclrt" intnum)

(setq tblmem (tblnext "dimstyle" 1))
(while (/= nil tblmem)
(setq stynme (cdr (assoc 2 tblmem)))
(command "-dimstyle" "restore" stynme)
(setvar "dimclrt" intnum)
(command "-dimstyle" "save" stynme "yes")
(setq tblmem (tblnext "dimstyle"))
);end while

(command "dimstyle" "restore" cursty)
(setvar "cmdecho" oldech)

(princ "Dimension color set to ") (princ intnum) (princ " for all styles.")
(princ)

);end function DCOL
[/Code]
Message 4 of 10
pnorman
in reply to: Anonymous

Hi Gary,

When using the [ code ] flags make sure all are lower case.

eg

[Code]
(defun active-document ()
(cond (*active-document*)   ; Return the cached object
   (t
    (setq *active-document* (vla-get-activedocument (acad-object)))
   )
)
)
[/Code]

eg

[code]
(defun active-document ()
(cond (*active-document*)   ; Return the cached object
   (t
    (setq *active-document* (vla-get-activedocument (acad-object)))
   )
)
)
[/code]
Message 5 of 10
pnorman
in reply to: Anonymous

Now that's wierd!!
I did a test and all seemed logical. Until I posted here!

The test:
http://discussion.autodesk.com/thread.jspa?threadID=470207

Cheers
Phill
Message 6 of 10
Anonymous
in reply to: Anonymous

Use Arial.ttf for font - you get thick text and looks good.
Message 7 of 10
Anonymous
in reply to: Anonymous

sorry I want .shx not TTF

--
Dave

"None" wrote in message
news:5161516@discussion.autodesk.com...
Use Arial.ttf for font - you get thick text and looks good.
Message 8 of 10
Anonymous
in reply to: Anonymous

Gary
Is there a way to make this code not try to modify external referenced
dimension styles

Unknown dimension style.

"Z-2700-1-AFP1|Aec-Arch-I-96": Invalid file name.
Unknown command "YES". Press F1 for help.
Invalid style name.

Unknown dimension style.

thankx

--
Dave

"Gary McMaster" wrote in message
news:5160644@discussion.autodesk.com...
Hi David,

I use code similar to that below to globally change the "dimscale" for all
dimstyles.
The sample below is modified to change the text color instead.

Hope it helps.

Gary

[Code]
;Globally change text color for all existing dimstyles.

(defun C:DCOL (/ cursty intnum tblmem stynme oldech)

(setq oldech (getvar "cmdecho"))
(setvar "cmdecho" 0)

(setq cursty (getvar "dimstyle"))
(setq intnum (getint "\nEnter new dimension text color: "))

(setvar "dimclrt" intnum)

(setq tblmem (tblnext "dimstyle" 1))
(while (/= nil tblmem)
(setq stynme (cdr (assoc 2 tblmem)))
(command "-dimstyle" "restore" stynme)
(setvar "dimclrt" intnum)
(command "-dimstyle" "save" stynme "yes")
(setq tblmem (tblnext "dimstyle"))
);end while

(command "dimstyle" "restore" cursty)
(setvar "cmdecho" oldech)

(princ "Dimension color set to ") (princ intnum) (princ " for all styles.")
(princ)

);end function DCOL
[/Code]
Message 9 of 10
Anonymous
in reply to: Anonymous

Hi David,

I don't do much with xrefs (or lisp), but it appears that the "|" (pipe
symbol) appears in the name of all xrefed dimstyles.

Below is a modified version that tests for the pipe symbol and skips any
style that contains it. Probably not the best way, but it seems to work.
I was hoping one of the lisp experts would chime in and show us a better way
to do this. Possibly without using "command" or having to set each style
current.

Gary

[code]
;Globally change text color for all existing dimstyles.

(defun C:DCOL (/ cursty intnum tblmem stynme oldech)

(setq oldech (getvar "cmdecho"))
(setvar "cmdecho" 0)

(setq cursty (getvar "dimstyle"))
(setq intnum (getint "\nEnter new dimension text color: "))

(setvar "dimclrt" intnum)

(setq tblmem (tblnext "dimstyle" 1))
(while (/= nil tblmem)
(setq stynme (cdr (assoc 2 tblmem)))
(if (= nil (wcmatch stynme "*|*"))
(progn
(command "-dimstyle" "restore" stynme)
(setvar "dimclrt" intnum)
(command "-dimstyle" "save" stynme "yes")
);progn
);if

(setq tblmem (tblnext "dimstyle"))
);end while

(command "dimstyle" "restore" cursty)
(setvar "cmdecho" oldech)

(princ "Dimension text color set to ") (princ intnum) (princ " for all
styles.")
(princ)

);end function DCOL
[/code]
Message 10 of 10
Anonymous
in reply to: Anonymous

Got it. Thanks for the heads up.

Gary

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost