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

0 Members and 1 Guest are viewing this topic.

zibidi

  • Guest
[SOLVED] Modifying dimension style attributes
« on: July 16, 2007, 05:12:53 PM »
Hi swampers,

I am trying to update my existing dimensions so that they meet the ISO standard. I want to create a pure Autolisp script that could do that for me for each dimension style in a drawing. Here is the option I am trying to reach:



I tried comparing the dimension style definition list when changing by hand ISO, but no difference appeared in the dxf codes  :|

So if anyone has an idea on which dxf code to change or which entity to play with...  :-)
« Last Edit: July 18, 2007, 12:04:13 PM by zibidi »

Jeff_M

  • King Gator
  • Posts: 4012
  • C3D user & customizer
Re: ISO dxf code for dimension style
« Reply #1 on: July 16, 2007, 05:48:56 PM »
Looks to me like this affects the 2 Sysvars DIMTIH & DIMTOH. It sets the TIH to OFF (0) and TOH to ON(1) in my testing.

zibidi

  • Guest
Re: ISO dxf code for dimension style
« Reply #2 on: July 16, 2007, 06:06:21 PM »
In the mean time I have experienced a very dangerous behavior from autolisp/autocad:

I have created a simple script that changes all the dimstyle text color to force it to white. And for unknown reasons, AutoCAD has decided that it would also change some other dimension style attribute as well or play with the <style overrides>, I didn't figure out what exactly it did. The huge problem is that I have dimensions that have a scale factor, so when I run my script, the dimensions that have the scale factor have it removed!!!  :x

Just by chance I spotted it, and I could retrieve my old drawings from my backup hard drive, otherwise I would have wasted months of work due to wrong dimensions.

That definitely marks the end of my autolisp experience. I can no longer rely on it, as AutoCAD behavior is too dangerous. On some drawings it works, on some other that have traps, it doesn't, and that is unacceptable for a software of that price. What would have happened if I had automated my script to run on a whole folder?! I would have never been able to see that autocad would trash some drawings!!!  :realmad:

AutoCAD is the biggest piece of crap I have ever encountered in my computing life! And you know what? The worst is that I have no other choice to keep using it as long as my customers and partners use it...

ronjonp

  • Needs a day job
  • Posts: 7305
Re: ISO dxf code for dimension style
« Reply #3 on: July 16, 2007, 06:17:39 PM »
I wouldn't put so much blame on the software....it sounds like you are doing something wrong. :?

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Jeff_M

  • King Gator
  • Posts: 4012
  • C3D user & customizer
Re: ISO dxf code for dimension style
« Reply #4 on: July 16, 2007, 06:24:34 PM »
I wouldn't put so much blame on the software....it sounds like you are doing something wrong. :?
I'd have to Echo that sentiment. As a general rule I won't execute a new routine on a batch job until I've tested it on a backup copy and inspected everything that it supposed to do, and verify that it's NOT doing something unintended.

The trouble with Dimensions is that each Style can have overrides which will be eliminated if the Parent style is altered without first saving the overrides to the parent. When doing this manually in the DimStyle Editor it warns you of this fact. Changing things programatically it is usually left up to the coder to make those decisions.

zibidi

  • Guest
Re: ISO dxf code for dimension style
« Reply #5 on: July 16, 2007, 06:30:29 PM »
Well, after calming down a little (I almost lost my business because of that), I have decided to give it one last chance.

Here is my script:
Code: [Select]
(defun C:DSP ( / dimStyleIdentifier dimStyleName dimStyleEntityName dimStyleEntity)

(setq dimStyleIdentifier (tblnext "DIMSTYLE" T)) ;get the first DIMSTYLE name and store it in dimStyleIdentifier
;Actually, it sets dimStyleIdentifier to the next dimstyle, but because there is the T
;parameter, it rewinds the table to the first entry of the DIMSTYLE table.
;The problem with tblnext is that it doesn't return a usable entity that can be updated with entmod. So we have
;to make a twist and first fetch the dimstylename, then fetch the correct dimstyle entity using tblobjname followed
; by an entget, then we can apply the entmod to update its attibutes.

(while dimStyleIdentifier
(setq dimStyleName (cdr (assoc 2 dimStyleidentifier))) ;fetch dimStyleIdentifier's name and store it in dimStyleName
(setq dimStyleEntityName (tblobjname "DIMSTYLE" dimStyleName)) ;fetch the dimstyle entity name.
(setq dimStyleEntity (entget dimStyleEntityName)) ;here we finally fetch the correct entity on which entmod can be invoked
(entmod (subst '(178 . 7) (assoc 178 dimStyleEntity) dimStyleEntity)) ;perform a substitution of the DXF code for DIMCLRT
;entmod is the function that actually applies the changes

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

(command "._DIM1" "update" "all" "") ;that's what updates the dimensions and redraws them white.

); ends the defun

The code is simple and I have commented it heavily so it'll be easy for you to understand. All I do, is make a substitution on the DXF code 178 which is the dimension style text color, and I force it to white. That's all my code does.

It seems, that the last line (command "._DIM1" "update" "all ""), is the one that deletes the <dimstyle override> (even though it shouldn't). The problem is that without this line, the changes don't get redrawn on the screen.

Anyone has an idea on that?

In my timezone, it is actually midnight, so I'll go to sleep, I hope the rest will give me some good advice on that enormous flaw.


EDIT: jeff_m you replied while I was writing this post. Yes definitely it is the fact that <dimstyle override> get deleted is what is causing me trouble.
« Last Edit: July 16, 2007, 06:40:08 PM by zibidi »

zibidi

  • Guest
Re: ISO dxf code for dimension style
« Reply #6 on: July 16, 2007, 06:34:04 PM »
Quote
The trouble with Dimensions is that each Style can have overrides which will be eliminated if the Parent style is altered without first saving the overrides to the parent.
That is an absolutely stupid behavior from autocad which I was not aware of, thank you for telling me. Why would overrides get removed? And I have been modifying the dimension style color by hand in the dimstyle editor, it has never notified me of any warning.

So how would you change my code to reflect that behavior? What I understand is that I first need to merge the override into the parent dimension style, then update the changes. Am I right?

PS: where did you manage to learn all that autolisp stuff? The help in autocad is... not very helpful.


EDIT: I have found out that to save dimstyle overrides one can issue at the command line:
Code: [Select]
-DIMSTYLE
SAVE
style-name
But I don't understand. How do I tell autocad to save the override I want. Using the snippet I gave above, it only saves one override. What about the other ones? Or can I simply reissue that command, and autocad will propose to save the next override?

Okay now I am going to bed.

EDIT: I tested the snippet, and it still trashes the scale factor of the dimstyle override that has been saved to an independent dimsension style. This is an absolute nonsense.  :ugly:
« Last Edit: July 16, 2007, 06:53:34 PM by zibidi »

Jeff_M

  • King Gator
  • Posts: 4012
  • C3D user & customizer
Re: ISO dxf code for dimension style
« Reply #7 on: July 16, 2007, 07:11:06 PM »
Oops, I typed without checking first. It is the "Set Current" that you cannot do without saving/losing your overrides.

Dim Update does just that. It updates the selected dimensions to be EXACTLY like that of the object's Dim Style.....which means it has to remove the object's dim overrides.

So, setting your DimStyle's properties will affect all new dimensions, but to change the existing dimensions to match the new style I think requires setting the override for EACH dimension object in the drawing, which is something easier done with ActiveX, IMHO. Otherwise you must modify the dictionary entry(ies) manually (that's where the overrides are stored). Alternatively you could probably save the overrides for each Dim object, use the Update, then reset the overrides for the objects. If anyone else knows differently, please chime in.

Just trying to throw out some ideas here. If you would like some help with any of them, just holler. :-)

The Help is helpful, when you eventually know what to look for :-) I learned by frequenting forums such as this and the Autodesk customization newsgroup. And LOTS of trial & error. :-/


Jeff_M

  • King Gator
  • Posts: 4012
  • C3D user & customizer
Re: ISO dxf code for dimension style
« Reply #8 on: July 16, 2007, 07:18:39 PM »
My curiosity got the best of me again......I went to the Adesk User's Guide (Help), Command Reference, Found "DIM1" and followed the link. Under the "UPDATE" description it says
Quote from: Equivalent Command
-DIMSTYLE Apply
. So I followed my nose to that command sequence and this is what that described:
Quote
Applies the current dimensioning system variable settings to selected dimension objects, permanently overriding any existing dimension styles applied to these objects.
So the results you obtained are what I would expect, and it confirms that one of the methods I spoke of above will be required to accomplish your task.



Krushert

  • Seagull
  • Posts: 13650
  • FREE BEER Tomorrow!!
Re: ISO dxf code for dimension style
« Reply #9 on: July 16, 2007, 07:33:34 PM »
My curiosity got the best of me again......
Okay mine kicked in as well but I just have questions.

Zibidi, why are you overriding the dimstyle?  It sounds like you are overriding every single dimension in the drawing with the script. That to me sounds like a lot of dimensions that need changing.  Would it not be easier to create different dimstyle and then change the dimensions to the new dimstyle, thus leaving the ones you do not what to change alone on the old dim style.

Just some thoughts here?
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here for camaraderie

Jeff_M

  • King Gator
  • Posts: 4012
  • C3D user & customizer
Re: ISO dxf code for dimension style
« Reply #10 on: July 16, 2007, 07:38:55 PM »
Hey zibidi, when you awaken and find all these posts please don't be put off by them...I'm really trying to help you out, not put you down. OK?

Anyway, I found another potential problem. That being that if the DimStyle's DIMCLRT value is the default of BYBLOCK (color 0) then it will not be in the (entget) list....which means there's nothing to modify with (subst), so that Style's Text color will not be revised per your code. Just thought you might want to know.

Jeff_M

  • King Gator
  • Posts: 4012
  • C3D user & customizer
Re: ISO dxf code for dimension style
« Reply #11 on: July 16, 2007, 07:43:33 PM »
Hi Krushert,
Yes, I'm pretty sure that zibidi's intent is to change all of the Dimension Text to be White. Which can be done as they were trying, but, as they also found out, updating the dimensions to the revised styles removes any overrides on those dimensions. So yes, I think each & every one needs to be modified individually.

Of course I could be way off base....  :| :?

Jeff_M

  • King Gator
  • Posts: 4012
  • C3D user & customizer
Re: ISO dxf code for dimension style
« Reply #12 on: July 16, 2007, 08:02:09 PM »
Of course I could be way off base....  :| :?
And I am......merely 'touching' the dim objects will update them with the revised style.....try grip editing one and the text will update to the new color. A quickie work around is to use
Code: [Select]
(command "erase" "all" "")
(command "oops")
And that updates them without mucking with the individual overrides.....this is why I quit fooling with dimensions along time ago.....

Krushert

  • Seagull
  • Posts: 13650
  • FREE BEER Tomorrow!!
Re: ISO dxf code for dimension style
« Reply #13 on: July 16, 2007, 08:03:52 PM »
Of course I could be way off base....  :| :?
Mostly likely I am.  I am more often than not.  :-)

Let me ask this question.  Is he making the problem bigger?  For example, he is currently dealling with past overrides and the only way to deal with them is make more overides today.  Then lets say 6 months in the future he needs to make more changes.  Then at that time he is dealing with the overrides prior to today, today's overrides and whatever he has to do in the future.

He is trying to become ISO compliant so it might be easier to change dimstyles.  How many past overridden dimensions per file when compared to the total number of virgin dimensions are we talking about.  Only he can answer this question becuase we do not know his situation. 

Hey zibidi, when you awaken and find all these posts please don't be put off by them...I'm really trying to help you out, not put you down. OK?
Same here Zibidi.  Basically I am asking are you tackling this from the right angle? 
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here for camaraderie

Krushert

  • Seagull
  • Posts: 13650
  • FREE BEER Tomorrow!!
Re: ISO dxf code for dimension style
« Reply #14 on: July 16, 2007, 08:06:40 PM »
And I am......merely 'touching' the dim objects will update them with the revised style.....try grip editing one and the text will update to the new color. A quickie work around is to use
Code: [Select]
(command "erase" "all" "")
(command "oops")
And that updates them without mucking with the individual overrides.....this is why I quit fooling with dimensions along time ago.....

What the ?   :-o :lmao:
Freakin Autocad
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here for camaraderie

zibidi

  • Guest
Re: ISO dxf code for dimension style
« Reply #15 on: July 17, 2007, 04:44:25 AM »
Here I am, cool and fresh!  :kewl:

Thanks guys for helping me out on this on. I was really mad yesterday!

Quote
Zibidi, why are you overriding the dimstyle?
I am not, it's AutoCAD that's doing it. Overrides are evil

Quote
Anyway, I found another potential problem. That being that if the DimStyle's DIMCLRT value is the default of BYBLOCK (color 0) then it will not be in the (entget) list....which means there's nothing to modify with (subst), so that Style's Text color will not be revised per your code. Just thought you might want to know.
For once I am lucky. The DIMCLRT color is forced to "yellow" (who the < > set them to yellow in the first place?)

Quote
Yes, I'm pretty sure that zibidi's intent is to change all of the Dimension Text to be White.
Yes. Currently the text appears yellow. The only little thing I want to do is turn it into white, that's it. Overrides or not I don't care. The only little thing I want to do is change a color from yellow to white.

Quote
this is why I quit fooling with dimensions along time ago.....
:lmao:

Quote
For example, he is currently dealling with past overrides and the only way to deal with them is make more overides today.  Then lets say 6 months in the future he needs to make more changes.  Then at that time he is dealing with the overrides prior to today, today's overrides and whatever he has to do in the future.
I am not trying to create new overrides, all I want to achieve is change the text color, now if autocad does this by creating overrides or some other cryptic behavior, that is not my fault. Changing an object's attribute should be the simplest thing on earth either by directly assigning its value (bad practice) or by using a setter method to which we can pass a parameter and takes care of setting the value accordingly.

What I am really trying to do, is change the text color as if I were doing it by hand in the dimstyle editor, it's as simple as that. Type: "dimstyle", select the dimstyle to edit, click "modify", then choose the "text" tab, select the white color, click "ok", then repeat for all dimstyles, click close, and all the dimstyles have now white text, no overrides or that kind of crap, no animal has been harmed during the process, and the environment has been preserved.  :-)

Now why this process cannot be "easily" mimicked in autolisp, that is another question...  :pissed:
« Last Edit: July 17, 2007, 12:04:40 PM by zibidi »

CADaver

  • Guest
Re: ISO dxf code for dimension style
« Reply #16 on: July 17, 2007, 10:11:55 AM »
.....this is why I quit fooling with dimensions along time ago.....
ummmm... what do you use instead??

CADaver

  • Guest
Re: Modifying dimension style attributes
« Reply #17 on: July 17, 2007, 10:24:15 AM »
hmmm... I step through each dimstyle, setting it current, changing the dimclrt, saving it, works just fine for me.  No need for "update" "all", this will not update those dims that have overridden the dim text color, however.

"Dim1 UPDATE ALL" does exactly what it is meant to do, make all the dimensions match the current settings.  If that's NOT what you wish to do then don't use that.

As far as I can see it's all working as it should.

zibidi

  • Guest
Re: Modifying dimension style attributes
« Reply #18 on: July 17, 2007, 12:01:39 PM »
Quote
hmmm... I step through each dimstyle, setting it current, changing the dimclrt, saving it, works just fine for me.
So if you have 30 dwgs and each drawing has 10 or more dimension styles, you don't mind clicking around 1500 times to make the changes?  :-o

Quote
"Dim1 UPDATE ALL" does exactly what it is meant to do, make all the dimensions match the current settings.  If that's NOT what you wish to do then don't use that.
Ok, you are the 3rd or 4th person who tells me that I am not using the correct command, thank you I appreciate that, now that I have got the point could we move a step forward?  So what's the function/command that redraws the dimensions according to the dxf definition? That's what I am looking for.

Quote
As far as I can see it's all working as it should.
Here are screenshots showing the trouble:

One this first one you see, that the dimension I have highlighted uses the ISONORM00 dimension style:


And on this one which is the DXF definition for ISONORM00, you can see that the DXF code #178 (the one in charge of DIMCLRT which is the text color) is set to 7 which is white. And you can clearly see that the text is still yellow unless you are color blinded or that I myself have troubles in seeing colors.


So as the dimension styles have got their attribute changed, how do I make autocad apply these changes? Yeah I know, no more DIM1 "update", so what else?

When using entmod to update the radius of a circle for instance, autocad redraws the circle immediately with no fuss, I have programmed it and tested it successfully.  ;-)
« Last Edit: July 17, 2007, 12:07:12 PM by zibidi »

CADaver

  • Guest
Re: Modifying dimension style attributes
« Reply #19 on: July 17, 2007, 01:08:06 PM »
Quote
hmmm... I step through each dimstyle, setting it current, changing the dimclrt, saving it, works just fine for me.
So if you have 30 dwgs and each drawing has 10 or more dimension styles, you don't mind clicking around 1500 times to make the changes?  :-o
First off I do the proper setup to begin with, secondly this works just fine in lisp

Quote
"Dim1 UPDATE ALL" does exactly what it is meant to do, make all the dimensions match the current settings.  If that's NOT what you wish to do then don't use that.
Ok, you are the 3rd or 4th person who tells me that I am not using the correct command, thank you I appreciate that, now that I have got the point could we move a step forward?  So what's the function/command that redraws the dimensions according to the dxf definition? That's what I am looking for.
Ya know, you can either lose the attitude or get lost, I personally don't care which.  If you want help, there are plenty around here that will, if you just want to pop-off, go to the adesk boards.

Once the dimstyle is saved there is no need in revising the dxf definition, no need for entmod.  That is unless you've, for some reason, already overidden the color of indivdual dims.

zibidi

  • Guest
Re: Modifying dimension style attributes
« Reply #20 on: July 17, 2007, 03:04:54 PM »
What's up CADaver,

I really love your sense of humor, it's kinda special to grasp at first, but it sure is cool.  8-)

Your second post was much more clear than the first one, and you have put me on a new track to explore.

By the way, in general is it a good practice to modify entities by accessing their DXF data or is it better to use as much autocad commands as possible? I suspect the latter to be the correct answer.

Here is my new proposal, I did it by typing it by hand in the command line:
Code: [Select]
-dimstyle
restore
name-of-the-dimstyle
(setvar "dimclrt" 7)
-dimstyle
save
name-of-the-dimstyle
yes
If I get your approval I can now edit my code and make it loop through this snippet and that would mean that it all works great!  :-)
« Last Edit: July 17, 2007, 03:16:25 PM by zibidi »

CADaver

  • Guest
Re: Modifying dimension style attributes
« Reply #21 on: July 17, 2007, 03:23:05 PM »
By the way, in general is it a good practice to modify entities by accessing their DXF data or is it better to use as much autocad commands as possible? I suspect the latter to be the correct answer.
Depends on what you're doing.  Most programers would probably prefer manipulating the element without calling the command.  In this case I'd use tblnext to step through each dimstyle making whatever changes needed through a while loop and cons.

If you have access to the old ddmodify.lsp function there is an excellent example of using tblnext "dimstyle" as I've indicated above.

Then again some "real" code guru like Charles or Michael or any of a dozen guys here can explain it better than I.

deegeecees

  • Guest
Re: Modifying dimension style attributes
« Reply #22 on: July 17, 2007, 03:23:49 PM »
zibidi,

If you are trying to do this through coding, then it would help us help you a bit more efficiently if you were to post the code you are working on. Other than that, it is an exercise in futility to keep trying to guess at what you need. So, in light of that, here are a cuple questions to clear things up:

1. Are you trying to create an application in Lisp?

1a. (Yes from #1) Can you post the code?

1b. (No from #1) Do you need help in figuring out how to manipulate dimstyles?

zibidi

  • Guest
Re: Modifying dimension style attributes
« Reply #23 on: July 17, 2007, 03:31:58 PM »
Hu?  :? I posted the code on the previous page, here is a direct link to it if you missed it: http://www.theswamp.org/index.php?topic=17631.msg213010#msg213010

However, the approach I used in it, i.e:access the DXF data of each dimstyle, is a dead end as CADaver said. I run into so many troubles when some dimstyles have overrides.

So based on CADaver's second post, which shed the light on a new path, I have proposed a small snippet that works for a single dimstyle. If someone tells me that this is the correct way to modify the dimstyle text color, then I can go forward and to it into a loop that goes through each dimstyle, and then run it on all my drawings. All I need to know is will I run into any other trouble that I am not aware of?

PS: if you didn't see my code, probably I am not using the correct tags, tell me if I am doing anything wrong.  :-)

LE

  • Guest
Re: Modifying dimension style attributes
« Reply #24 on: July 17, 2007, 03:33:45 PM »
something like this ?

edit by me...the image is not needed anymore.
« Last Edit: July 17, 2007, 04:33:47 PM by LE »

deegeecees

  • Guest
Re: Modifying dimension style attributes
« Reply #25 on: July 17, 2007, 03:36:47 PM »
OOOoooops!

Ok, help is on the way. My apologies zibidi!

zibidi

  • Guest
Re: Modifying dimension style attributes
« Reply #26 on: July 17, 2007, 03:53:00 PM »
@LE: yep that's typically want I want to do, except that I want autolisp to do it for me, I am fed up clicking a hundred times. What did you use for the screencast? That was cool, I want to do the same! camstasia? fraps?

@deegeecees: no problem, I should have highlighted my code to me more clear.

By the way I tried a fully functional program, but for some reason it doesn't work:
Code: [Select]
(defun C:DSP (/ dimStyleIdentifier)
(setq dimStyleIdentifier (tblnext "DIMSTYLE" T)) ;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
It doesn't seem to be taking my dimStyleIdentifier.  :x

LE

  • Guest
Re: Modifying dimension style attributes
« Reply #27 on: July 17, 2007, 04:00:10 PM »
@LE: yep that's typically want I want to do, except that I want autolisp to do it for me, I am fed up clicking a hundred times. What did you use for the screencast? That was cool, I want to do the same! camstasia? fraps?

yes it is camtasia studio... the routine is all done in lisp... the functions can be call to simple tell autocad to the appropriate updates to the dimstyles... the routine uses an ini file, and I have my standards in there, so no need to do any clicking, just to set when needed the dimension and text styles.

zibidi

  • Guest
Re: Modifying dimension style attributes
« Reply #28 on: July 17, 2007, 04:05:08 PM »
Arghh!!

I tried this:
Code: [Select]
(defun C:DSP (/ dimStyleIdentifier)
(command "._DIMSTYLE" "restore" "08")
(setvar "dimclrt" 7)
(command "._DIMSTYLE" "save" "08" "Y")
) ;end the defun
And it works. This means my dimStyleIdentifier is not recognized. Hmm....  :-(

CADaver

  • Guest
Re: Modifying dimension style attributes
« Reply #29 on: July 17, 2007, 04:05:27 PM »
Code: [Select]
(command "._DIMSTYLE" "R" (cdr (assoc 2 dimStyleIdentifier)))

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: 4012
  • 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!