Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*David Allen
Message 1 of 10 (86 Views)

Need code to modify all dimstyles

86 Views, 9 Replies
05-01-2006 11:49 AM
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
*Gary McMaster
Message 2 of 10 (86 Views)

Re: Need code to modify all dimstyles

05-02-2006 04:34 AM in reply to: *David Allen
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:smileyvery-happy:COL (/ 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]
*David Allen
Message 3 of 10 (86 Views)

Re: Need code to modify all dimstyles

05-02-2006 11:42 AM in reply to: *David Allen
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:smileyvery-happy:COL (/ 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]
Distinguished Contributor
pnorman
Posts: 614
Registered: ‎02-24-2006
Message 4 of 10 (86 Views)

Re: Need code to modify all dimstyles

05-02-2006 12:02 PM in reply to: *David Allen
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]
Distinguished Contributor
pnorman
Posts: 614
Registered: ‎02-24-2006
Message 5 of 10 (86 Views)

Re: Need code to modify all dimstyles

05-02-2006 12:05 PM in reply to: *David Allen
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
*None
Message 6 of 10 (86 Views)

Re: Need code to modify all dimstyles

05-02-2006 01:24 PM in reply to: *David Allen
Use Arial.ttf for font - you get thick text and looks good.
*David Allen
Message 7 of 10 (86 Views)

Re: Need code to modify all dimstyles

05-02-2006 01:44 PM in reply to: *David Allen
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.
*David Allen
Message 8 of 10 (86 Views)

Re: Need code to modify all dimstyles

05-05-2006 08:20 AM in reply to: *David Allen
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:smileyvery-happy:COL (/ 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]
*Gary McMaster
Message 9 of 10 (86 Views)

Re: Need code to modify all dimstyles

05-08-2006 05:18 AM in reply to: *David Allen
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:smileyvery-happy:COL (/ 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]
*Gary McMaster
Message 10 of 10 (86 Views)

Re: Need code to modify all dimstyles

05-08-2006 05:20 AM in reply to: *David Allen
Got it. Thanks for the heads up.

Gary
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.