+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Junior Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2015
    Posts
    22

    Default Problem with macro for creating several dimension styles

    Registered forum members do not see this ad.

    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? <N>:_dimclrd
    Invalid option keyword.
    That name is already in use, redefine it? <N>:"

    "_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;

    Code:
    ^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

  2. #2
    Luminous Being RobDraw's Avatar
    Using
    MEP 2017
    Join Date
    Apr 2007
    Location
    Connecticut, USA
    Posts
    5,161

    Default

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

  3. #3
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,748

    Default

    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.

    Code:
    (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
    )
    A man who never made mistakes never made anything

  4. #4
    Super Moderator SLW210's Avatar
    Computer Details
    SLW210's Computer Details
    Operating System:
    Windows 7 PRO 64-bit
    Computer:
    IBM Lenovo
    Motherboard:
    ACPI x64
    CPU:
    Pentium(R) i5 4570 @ 3.2GHz
    RAM:
    8 GB RAM
    Graphics:
    Nvidia Quadro 600 1GB
    Primary Storage:
    300 GB
    Secondary Storage:
    650GB
    Monitor:
    2x ThinkVision 24"
    Discipline
    Multi-disciplinary
    SLW210's Discipline Details
    Occupation
    Design Draftsman
    Discipline
    Multi-disciplinary
    Details
    Mostly do drafting related to manufacturing. From doing site layouts with proposed updates, additions and renovations to be budgeted and submitted for bid, to updating and changing existing drawings to reflect maintenance and repair/revision work done on site.
    Using
    AutoCAD 2011
    Join Date
    May 2007
    Location
    South Florida, USA
    Posts
    11,734

    Default

    Or create all the dimstyles and add to the drawing template.
    “A narrow mind and a fat head invariably come on the same person” Zig Zigler



  5. #5
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,748

    Default

    Yeah SLW210 much easier to remove than add.
    Or
    Make a dwg with all dimstyles using 1 dim, then just copy and paste.
    A man who never made mistakes never made anything

  6. #6
    Junior Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2015
    Posts
    22

    Default

    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.

  7. #7
    Forum Deity steven-g's Avatar
    Computer Details
    steven-g's Computer Details
    Operating System:
    Win 7
    Discipline
    Construction
    steven-g's Discipline Details
    Occupation
    Draughtsman
    Discipline
    Construction
    Details
    I work in the estimating department of a large building contractor.
    Using
    AutoCAD 2017
    Join Date
    May 2013
    Location
    An Englishman in Belgium
    Posts
    2,043

    Default

    Just add
    Code:
    ;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
    Code:
    -dimstyle;s;"scale 1";
    should become
    Code:
    -dimstyle;s;"scale 1";yes;

  8. #8
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,748

    Default

    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.
    Last edited by BIGAL; 23rd Jul 2015 at 10:27 am.
    A man who never made mistakes never made anything

  9. #9
    Super Member
    Computer Details
    tombu's Computer Details
    Operating System:
    Windows 7 64-bit
    Computer:
    Dell
    Discipline
    Civil
    tombu's Discipline Details
    Occupation
    Design Analyst
    Discipline
    Civil
    Details
    Small Street & Stormwater projects. Traffic Calming and other issues.
    Using
    Civil 3D 2018
    Join Date
    Dec 2010
    Location
    Tallahassee, FL USA
    Posts
    717

    Default

    Quote Originally Posted by RobDraw View Post
    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.

  10. #10
    Junior Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2015
    Posts
    22

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by steven-g View Post
    Just add
    Code:
    ;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
    Code:
    -dimstyle;s;"scale 1";
    should become
    Code:
    -dimstyle;s;"scale 1";yes;
    Thank you very much Steven-G!

    How easy it can be....

Similar Threads

  1. Problem with macro for creating several dimensional styles
    By Sandervp in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 8
    Last Post: 27th Mar 2015, 12:00 pm
  2. creating styles
    By mfurches in forum Autodesk Inventor
    Replies: 0
    Last Post: 30th Nov 2012, 12:10 am
  3. VBA - Dimension Styles
    By wannabe in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 21st Oct 2008, 06:18 pm
  4. Dimension Styles
    By rush02112 in forum Autodesk Inventor
    Replies: 2
    Last Post: 16th Jun 2007, 10:25 pm
  5. Dimension Styles
    By JaketheMan in forum AutoCAD General
    Replies: 1
    Last Post: 15th May 2007, 11:43 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts