Author Topic: [SOLVED] Modifying dimension style attributes  (Read 16546 times)

0 Members and 1 Guest are viewing this topic.

deegeecees

  • Guest
Re: Modifying dimension style attributes
« Reply #30 on: July 17, 2007, 04:16:45 PM »
Not tested, but should work:

Code: [Select]
(defun C:DSP (/ dimStyleIdentifier)
(setq dimStyleIdentifier [color=red](cdr (assoc 2 [/color] (tblnext "DIMSTYLE" T))[color=red]))[/color] ;get the first DIMSTYLE name and store it in dimStyleIdentifier

(while dimStyleIdentifier
(command "._DIMSTYLE" "R" dimStyleIdentifier)
(setvar "dimclrt" 7)
(command "._DIMSTYLE" "S" dimStyleIdentifier "Y")

(setq dimStyleIdentifier (tblnext "DIMSTYLE")) ;get the next dimstyle
) ;ends the while loop
) ;end the defun

CADaver

  • Guest
Re: Modifying dimension style attributes
« Reply #31 on: July 17, 2007, 04:18:41 PM »
Code: [Select]
(defun C:DSP (/ dimStyleIdentifier)
(setq dimStyleIdentifier [color=red](cdr (assoc 2 [/color] (tblnext "DIMSTYLE" T))[color=red]))[/color] ;get the first DIMSTYLE name and store it in dimStyleIdentifier

(while dimStyleIdentifier
(command "._DIMSTYLE" "R" dimStyleIdentifier)
(setvar "dimclrt" 7)
(command "._DIMSTYLE" "S" dimStyleIdentifier "Y")

(setq dimStyleIdentifier [color=red](cdr (assoc 2 [/color] (tblnext "DIMSTYLE"))[color=red]))[/color] ;get the next dimstyle
) ;ends the while loop
) ;end the defun
« Last Edit: July 17, 2007, 04:19:42 PM by CADaver »

deegeecees

  • Guest
Re: Modifying dimension style attributes
« Reply #32 on: July 17, 2007, 04:19:28 PM »
Ahhh, yes.

zibidi

  • Guest
Re: Modifying dimension style attributes
« Reply #33 on: July 17, 2007, 04:25:54 PM »
Yeepeee!!! Excellent! Brilliant! Perfect!

Thanks a lot CADaver! You made my day! I owe you one!

Just to be sure, will there be any other cryptic behavior from autocad? I tried on a drawing that had overrides and it all went all smoothly, but are we sure that it will work on 100% drawings? What are the pitfalls that I might drop into?

So here is the complete functional code if anyone is interested in. Nice and clean with comments for learning easier from it.
Code: [Select]
(defun C:DSP (/ dimStyleIdentifier)
;So in this script, we will change all dimstyle text color to white.
;In order to do this, we won't be accessing the DXF attributes of the dimstyles
;using entget+entmod because of problems with <dimstyle overrides>.
;We will loop through each dimstyle, set it to the current dimstyle using
;AutoCAD's "DIMSTYLE" command, then set its DIMCLRT value to white (i.e:7)
;then save the current dimstyle back to the same name.

(setq dimStyleIdentifier (cdr (assoc 2 (tblnext "DIMSTYLE" T)))) ;get the first DIMSTYLE name and store it in dimStyleIdentifier
; the cdr(assoc 2 (...)) is necessary, because (tblnext "DIMSTYLE) returns a big list which is the DXF
;definition of the dimstyle. So we have to extract only its name. The DXF code for the name is #2.

(while dimStyleIdentifier
(command "._DIMSTYLE" "R" (cdr (assoc 2 dimStyleIdentifier))) ;invoke the "DIMSTYLE" autoCAD command
;and set the current dimstyle to be dimStyleIdentifier

(setvar "dimclrt" 7) ;set the DIMCLRT value to 7, i.e: text color to white
(command "._DIMSTYLE" "save" (cdr (assoc 2 dimStyleIdentifier)) "Y"); save the dimstyle

(setq dimStyleIdentifier (cdr (assoc 2 (tblnext "DIMSTYLE" T)))) ;get the next dimstyle
) ;ends the while loop
) ;end the defun
If you think there is a cleaner way to do things, please give me a shout. It's by learning from the pros that we get better!

That's cool, now I learned how to use DXF manipulation, using AutoCAD commands, what else do I need? Learn the commands reference guide better?

It's bed time for me, see you soon  :kewl:

EDIT: later this week, I will code a text translator for changing text that is on the drawing, let's see if I can get it right the first time  :pissed:
« Last Edit: July 17, 2007, 04:29:01 PM by zibidi »

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Modifying dimension style attributes
« Reply #34 on: July 17, 2007, 04:31:12 PM »
.....this is why I quit fooling with dimensions along time ago.....
ummmm... what do you use instead??
I didn't say I don't use them, I said I quit fooling with them.....and could/should have added  "in code". IOW, I set them up how I want them in the beginning and don't need/want to change them, especially with (entmod). :-)

zibidi, I'm glad you got it all straightened out.

LE

  • Guest
Re: Modifying dimension style attributes
« Reply #35 on: July 17, 2007, 04:32:08 PM »
that's good.

cadaver and deegeecees pretend that they don't know, but as you have seen, they came up with a simple routine. :)
« Last Edit: July 17, 2007, 04:34:28 PM by LE »

deegeecees

  • Guest
Re: Modifying dimension style attributes
« Reply #36 on: July 17, 2007, 04:33:48 PM »
I'm just a hack.

 :wink:

deegeecees

  • Guest
Re: Modifying dimension style attributes
« Reply #37 on: July 17, 2007, 04:36:03 PM »
Quote
...Learn the commands reference guide better?

Yes. It's quite handy when you finally "get it", as well as the Developer Documentation.

CADaver

  • Guest
Re: Modifying dimension style attributes
« Reply #38 on: July 17, 2007, 04:37:09 PM »
.....this is why I quit fooling with dimensions along time ago.....
ummmm... what do you use instead??
I didn't say I don't use them, I said I quit fooling with them.....and could/should have added  "in code". IOW, I set them up how I want them in the beginning and don't need/want to change them, especially with (entmod). :-)
ahh okay, you had me wondering there for a minute.  We have a dimset function that runs at startup and several that we use to set a few things along the way, but by and large we don't fiddle with them either.

zibidi, I'm glad you got it all straightened out.
^^
 x2

CADaver

  • Guest
Re: Modifying dimension style attributes
« Reply #39 on: July 17, 2007, 04:37:30 PM »
« Last Edit: July 17, 2007, 04:38:33 PM by CADaver »

deegeecees

  • Guest
Re: Modifying dimension style attributes
« Reply #40 on: July 17, 2007, 04:38:28 PM »
 :-D

LE

  • Guest
Re: Modifying dimension style attributes
« Reply #41 on: July 17, 2007, 04:40:41 PM »
I'm just a hack.
I'm a hack thief.

He he....


Well as all you know I am a Janitor.... so what a heck.....  :lmao:

deegeecees

  • Guest
Re: Modifying dimension style attributes
« Reply #42 on: July 17, 2007, 04:41:32 PM »
Custodial Technician!