Jump to content
Sandervp

Problem with macro for creating several dimension styles

Recommended Posts

Sandervp

Hello everybody,

 

I've created a macro for creating different dimension styles for different scales. We are using these dimension styles in our company. It works well if I use it in a new, empty drawing.

But if I use it in an excisting drawing with a dimension style with the same name, I have got a problem.....

 

I'll see this in the command line;

 

"Enter name for new dimension style or [?]: "scale 20"

That name is already in use, redefine it? :_dimclrd

Invalid option keyword.

That name is already in use, redefine it? :"

 

"_dimclrd" should be the next command in the macro, but because "scale 20" is already in use, I need to do some other commands first.

AutoCad stops with this macro at this point. If the first dimension style, which the macro should be create, already in use, the other dimension styles shall not be create.

 

Is there a possibility/ sollution to change my macro so he creates every dimension style what he supposed to do? Also if one or more dimension styles already excist?

 

The reason why; if you delete a dimension style because you think; "I don't need him any more." But you're wrong. Or somebody else goes further with the drawing and needs to draw something with another scale.

You need to copy the 'wanted' dimension style from another (new/ excisting) drawing.

 

Could somebody help me?

 

This is the whole macro;

 

^C^C_dimclrd;1;dimltype;continuous;_dimlwd;-1;_dimdle;1.25;_dimdli;1.25;_dimclre;1;_dimltex1;continuous;_dimltex2;continuous;_dimlwe;-1;_dimexe;1.25;_dimexo;1.25;_dimblk;"";_dimldrblk;"";_dimasz;2;_dimcen;0;-style;;iso.shx;a;;;0;;;;;no;_dimtxsty;standard;_Dimclrt;2;_dimtfill;1;_dimtxt;1.8;_dimtad;1;_dimgap;1;_dimtoh;off;_dimtih;off;_dimtmove;0;_dimscale;1;_dimdec;0;_dimzin;0;_dimtolj;0;_dimse1;off;_dimse2;off;_dimrnd;5;_dimtofl;on;-dimstyle;s;"scale 1";_dimclrd;1;dimltype;continuous;_dimlwd;-1;_dimdle;1.25;_dimdli;1.25;_dimclre;1;_dimltex1;continuous;_dimltex2;continuous;_dimlwe;-1;_dimexe;1.25;_dimexo;1.25;_dimblk;"";_dimldrblk;"";_dimasz;2;_dimcen;0;-style;;iso.shx;a;;;0;;;;;no;_dimtxsty;standard;_Dimclrt;2;_dimtfill;1;_dimtxt;1.8;_dimtad;1;_dimgap;1;_dimtoh;off;_dimtih;off;_dimtmove;0;_dimscale;2;_dimdec;0;_dimzin;0;_dimtolj;0;_dimse1;off;_dimse2;off;_dimrnd;5;_dimtofl;on;-dimstyle;s;"scale 2";_dimclrd;1;dimltype;continuous;_dimlwd;-1;_dimdle;1.25;_dimdli;1.25;_dimclre;1;_dimltex1;continuous;_dimltex2;continuous;_dimlwe;-1;_dimexe;1.25;_dimexo;1.25;_dimblk;"";_dimldrblk;"";_dimasz;2;_dimcen;0;-style;;iso.shx;a;;;0;;;;;no;_dimtxsty;standard;_Dimclrt;2;_dimtfill;1;_dimtxt;1.8;_dimtad;1;_dimgap;1;_dimtoh;off;_dimtih;off;_dimtmove;0;_dimscale;10;_dimdec;0;_dimzin;0;_dimtolj;0;_dimse1;off;_dimse2;off;_dimrnd;5;_dimtofl;on;-dimstyle;s;"scale 10";_dimclrd;1;dimltype;continuous;_dimlwd;-1;_dimdle;1.25;_dimdli;1.25;_dimclre;1;_dimltex1;continuous;_dimltex2;continuous;_dimlwe;-1;_dimexe;1.25;_dimexo;1.25;_dimblk;"";_dimldrblk;"";_dimasz;2;_dimcen;0;-style;;iso.shx;a;;;0;;;;;no;_dimtxsty;standard;_Dimclrt;2;_dimtfill;1;_dimtxt;1.8;_dimtad;1;_dimgap;1;_dimtoh;off;_dimtih;off;_dimtmove;0;_dimscale;20;_dimdec;0;_dimzin;0;_dimtolj;0;_dimse1;off;_dimse2;off;_dimrnd;5;_dimtofl;on;-dimstyle;s;"scale 20";_dimclrd;1;dimltype;continuous;_dimlwd;-1;_dimdle;1.25;_dimdli;1.25;_dimclre;1;_dimltex1;continuous;_dimltex2;continuous;_dimlwe;-1;_dimexe;1.25;_dimexo;1.25;_dimblk;"";_dimldrblk;"";_dimasz;2;_dimcen;0;-style;;iso.shx;a;;;0;;;;;no;_dimtxsty;standard;_Dimclrt;2;_dimtfill;1;_dimtxt;1.8;_dimtad;1;_dimgap;1;_dimtoh;off;_dimtih;off;_dimtmove;0;_dimscale;50;_dimdec;0;_dimzin;0;_dimtolj;0;_dimse1;off;_dimse2;off;_dimrnd;5;_dimtofl;on;-dimstyle;s;"scale 50";_dimclrd;1;dimltype;continuous;_dimlwd;-1;_dimdle;1.25;_dimdli;1.25;_dimclre;1;_dimltex1;continuous;_dimltex2;continuous;_dimlwe;-1;_dimexe;1.25;_dimexo;1.25;_dimblk;"";_dimldrblk;"";_dimasz;2;_dimcen;0;-style;;iso.shx;a;;;0;;;;;no;_dimtxsty;standard;_Dimclrt;2;_dimtfill;1;_dimtxt;1.8;_dimtad;1;_dimgap;1;_dimtoh;off;_dimtih;off;_dimtmove;0;_dimscale;100;_dimdec;0;_dimzin;0;_dimtolj;0;_dimse1;off;_dimse2;off;_dimrnd;5;_dimtofl;on;-dimstyle;s;"scale 100";

 

Thanks

Share this post


Link to post
Share on other sites
RobDraw

It has to be mentioned that annotative dimensions are very useful in eliminating the need for having different dimension styles just for different scales.

Share this post


Link to post
Share on other sites
BIGAL

I would not do a macro that long rather convert it to a lisp then you can do a SEARCH for dim style existing and create a new one or overwrite the old one. ^c^c(load "checkdims") thats my macro. Have a look for a entmake dim style.

 

(setq  doc (vla-get-activedocument (vlax-get-acad-object))) ; open database
(setq dstyle (vla-get-dimstyles doc))

(vlax-for sty dstyle
(princ (vla-get-name sty)) ; put a make dim style here using a if
)

Share this post


Link to post
Share on other sites
SLW210

Or create all the dimstyles and add to the drawing template.

Share this post


Link to post
Share on other sites
BIGAL

Yeah SLW210 much easier to remove than add.

Or

Make a dwg with all dimstyles using 1 dim, then just copy and paste.

Share this post


Link to post
Share on other sites
Sandervp

The problem is that we have to change all the dimension styles. My company wants that every dimension style used in a drawing is a dimension with a closed filled arrow. At this moment we use dimension styles with an oblique.

 

These "oblique" dimension are having the same name like the "closed filled" dimension.

 

If I copy the new dimlinear from the one to the other drawing, with the old dimension styles, the new dimlinear is changing to the old one.

Share this post


Link to post
Share on other sites
steven-g

Just add

;yes

after each style name, if the style exists it will be redefined, if it doesn't exist the "yes" will return an unknown command error, but the macro will continue either creating new styles or redefining existing ones.

By the way the only thing that appears to change between styles is the _dimscale value, so after the first time the other variables are set there is no need to keep repeating them, which will cut your macro size down considerably, or at least make it easier to add extra styles in the future.

EDIT just to be clear

-dimstyle;s;"scale 1";

should become

-dimstyle;s;"scale 1";yes;

Share this post


Link to post
Share on other sites
BIGAL

Now that you have narrowed it down to whats required and you have Autocad you should be able to do a simple search through all existing dim styles and change to closed arrow it will mean a little bit more on the sample code I posted previously, any one else ? jump in.

 

So change DIMSAH, DIMBLK1 & 2 need to do some testing. Tharwat has some code that is close.

Edited by BIGAL

Share this post


Link to post
Share on other sites
tombu
It has to be mentioned that annotative dimensions are very useful in eliminating the need for having different dimension styles just for different scales.

 

I can remember having about 20 dim styles 20 years ago in r12, Annotative dimensions really simplified things. I now have 3 Annotative dim styles with Angular child styles in my templates.

Share this post


Link to post
Share on other sites
Sandervp
Just add
;yes

after each style name, if the style exists it will be redefined, if it doesn't exist the "yes" will return an unknown command error, but the macro will continue either creating new styles or redefining existing ones.

By the way the only thing that appears to change between styles is the _dimscale value, so after the first time the other variables are set there is no need to keep repeating them, which will cut your macro size down considerably, or at least make it easier to add extra styles in the future.

EDIT just to be clear

-dimstyle;s;"scale 1";

should become

-dimstyle;s;"scale 1";yes;

 

Thank you very much Steven-G!

 

How easy it can be....

Share this post


Link to post
Share on other sites
Sandervp

Thanks everybody to try to help me! :D

Share this post


Link to post
Share on other sites
tombu

One more option to consider is to use Lee Mac's Steal lisp to import all your Dimension Styles from another drawing. http://www.lee-mac.com/steal.html

This macro would load StealV1-8.lsp if needed and import DimStyle1 & DimStyle2 from C:\\My Folder\\MyDrawing.dwg

^C^C^P(or Steal (load "StealV1-8.lsp"))(Steal "C:\\My Folder\\MyDrawing.dwg" '(("Dimension Styles"("DimStyle1" "DimStyle2")))) 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...