Lisp - Altering dimension properties

Discussion in 'AutoCAD' started by Brian W., Dec 19, 2006.

  1. Brian W.

    Brian W. Guest

    I'm trying to write a Lisp that will change all of the dimensions
    settings in an open drawing. My company used to use arrow heads
    (Closed filled) for all their dimensions and would like to switch to
    using Architectural tick marks.
    The problem is that when we are using a drawing of something we have
    created in the past, all of the dimensions have arrows and we have to
    manually change all of the dimension's arrows, one by one, to arch
    ticks. I know there is a way to do this in Lisp, I just haven't been
    able to find it on the web. Any help would be greatly appreciated!

    Thank You,
    -Brian
    AutoCAD 2006
     
    Brian W., Dec 19, 2006
    #1
  2. Brian W.

    ddpcad Guest

    why not just use Quick Select? Grip highlight one dimension in the
    drawing, right click and pick Quick Select. Appy to: Entire Drawing,
    Object type: Rotated Dimension, Properties: Arrow1; Operator; = Equals;
    Value: Closed Filled, and hit OK. All of your dimensions in the drawing
    will be grip highlighted. Use Properties to change the Arrow1 and Arrow2
    values to Architectural Tick. Done
    Dave
    DDP
     
    ddpcad, Dec 19, 2006
    #2
  3. Brian W.

    Brian W. Guest

    Dave, thanks for your reply.
    My question still remains though. While it is true that it is not a
    difficult operation to perform, my boss has asked me to solve this
    problem with a program. I just need the right set of lisp commands to
    do it and I can't find out them! Any help would be greatly
    appreciated.

    Thank You,
    Brian
     
    Brian W., Dec 19, 2006
    #3
  4. Brian W.

    ddpcad Guest

    well, IMO, it would be more difficult than is seems on the surface but
    then I'm not a full fledged lisp programmer either. I've never had any
    need to do this programmatically because it's so simple to do other
    ways. Another simple way is to create a new dimstyle in your drawing
    using an existing style and change the arrow heads to Arch ticks and
    covert all existing dims to the new dimstyle. Would take about 30
    seconds max

    if you must persue this in lisp the group codes you're looking for are
    5, 6, 7, and 173 for DIMBLK, DIMBLK1, DIMBLK2, and DIMSAH. You can find
    references to those system variables in Help.

    sorry I couldn't be of more help,
    Dave
    DDP
     
    ddpcad, Dec 19, 2006
    #4
  5. That's not quite true. You can modify the dimension style, and use
    DIM>>UPDATE.

    You could also import a new dimension style(s) make it current, and then
    Dim>>up

    You could also WBLOCK your drawings into new templates that have the style
    as you want it. All should revert unless there were overrides to begin with.

    It's not a lisp solution, I know, but what you're asking is going to be
    tough and/or unlikely.
     
    Michael Bulatovich, Dec 19, 2006
    #5
  6. Brian W.

    Brian W. Guest

    I just tried this code:
    (command "DIMBLK" "ARCHTICK" "DIM" "UPDATE" "ALL" "" "EXIT")
    It does the trick with one catch... It updates all of the dimensions
    (scale, colors, text height, etc.) to the current dimstyle, AND changes
    the leaders to the current dimstyle. The problem is that most of these
    drawings have various dimstyles (scales, colors, text heights, etc.)
    and THOSE dimstyles MUST stay the same, with the exception of the
    DIMBLK1 and DIMBLK2. It also can not affect the leaders. I think we
    are definately making progress though and I appreciate any further help
    you can give!

    Brian W.
     
    Brian W., Dec 19, 2006
    #6
  7. You have discovered the problem with your approach. I suggest one of the
    dimstyle approaches.
     
    Michael Bulatovich, Dec 19, 2006
    #7
  8. Brian W.

    Brian W. Guest

    Here is the code I have right now:
    (command "DIMBLK" "ARCHTICK" "DIMBLK1" "ARCHTICK" "DIMBLK2"
    "ARCHTICK")
    (sssetfirst nil (ssget "_X" '((0 . "DIMENSION"))))
    (command "DIM" "UPDATE" "PREV" "" "EXIT")
    This sets the dimstyle for archticks, selects all of the dimensions,
    and then updates them. The same problem still exists though, in that
    if the existing dimensions have different scales, colors, etc. they are
    all modified. I think what I really need to happen is the following
    pseudo-code:

    -Create a list of every dimension in the drawing
    -Create a list of every dimension in the drawing's dimstyle
    -Loop for each dimension
    -Set the dimstyle of the dimension to the current dimstyle
    -Set the DIMBLK, DIMBLK1, and DIMBLK2 variables to "ARCHTICK"
    -Update ONLY that one dimension
    -End Loop

    Is this even possible? Any help would be GREATLY appreciated!!!

    Thank You,
    Brian W.
     
    Brian W., Dec 20, 2006
    #8
  9. If you really must go this route, you need to be more precise in making your
    selection set. Sort for group codes related to linear dimensions ( group
    code 0 ) *and* the particular style you want to change (group code 3).
    You're getting pretty close...
    --


    MichaelB
    www.michaelbulatovich.ca

     
    Michael Bulatovich, Dec 20, 2006
    #9
  10. Brian W.

    Brian W. Guest

    Michael, you are talking to a lisp amateur! I'm doing this as an
    update to a much larger lisp program and this is just an add-on. I can
    do basic stuff, like debugging and simple changes, but when it comes to
    what your talking about, I'm lost!!! I guess what I need to be asking
    for is if there is anyone out there with code similar to the
    pseudo-code I wrote, or how I would loop through every dimension in a
    drawing? Again, thanks for all the help!

    Brian W.
     
    Brian W., Dec 20, 2006
    #10
  11. (setq ss (ssget "_X" '((0 . "DIMENSION"))))
    (setq ss2(ssadd))
    (setq counter (- (sslength ss) 1))
    (while (>= counter 0)
    (setq ent(entget(ssname ss counter)))
    (if (member '(3 . "Standard") ent)
    (ssadd (ssname ss counter) ss2))
    (setq counter (1- counter))
    )

    This gives you a set named ss2 with all the dims in a drawing sith the style
    "standard". Change the style name and apply your function to that second
    set.

    --


    MichaelB
    www.michaelbulatovich.ca
     
    Michael Bulatovich, Dec 20, 2006
    #11
  12. Brian W.

    Brian W. Guest

    Each one of these drawings (and there are many thousands) have many
    dimensions in them with a variety of different style names other than
    "Standard" (close to 40 different style names used for dimensions). If
    I was to limit my selection set to just one of them each time, my code
    would go on forever.
    When I use this function:

    (sssetfirst nil (ssget "_X" '((0 . "DIMENSION"))))
    (princ)

    All of the dimensions in a drawing are selected and put a set. From
    there I can use the properties within AutoCad to change the Arrow1 and
    Arrow2 properties. The scale, color, etc remains unchanged and the
    ticks are the correct size for each individual dimension. Is there a
    way within lisp to change the Arrow1 and Arrow2 properties? Thanks
    again for all the help and effort!

    Brian W.

     
    Brian W., Dec 20, 2006
    #12
  13. Can you describe which dimensions you are trying to change and which you are
    not?
     
    Michael Bulatovich, Dec 20, 2006
    #13
  14. Brian W.

    Brian W. Guest

    I'm trying to change EVERY dimension in the drawing! They have a
    variety of different dimstyles (scale, color, etc) with different sized
    arrows and text in each individual drawing. There are close to 40
    different style names used (ex. M1, M2, M3, DS1, DS2, DS3, 1, 2, 3,
    etc) in each drawing. There are many different dim types (linear,
    aligned, arc length, etc) in each drawing. Every dimension, no matter
    the type, style, or scale should have the "Arrow1" and "Arrow2" values
    changed from "Closed filled" to "Architectural tick". This should be
    the only value that changes. The type, style, scale, color, etc. for
    each individual dimension should remain unchanged. In every drawing I
    open and run the code, every dimension in that opened drawing should
    have the Arrows converted to Archticks as if you selected 1 dimension
    in the drawing, changed the Arrow1 and Arrow2 values by hand, and
    repeated this process until all dimensions in the drawing have been
    changed.

    Short answer, ALL of them!

    Thanks,
    Brian W.

     
    Brian W., Dec 21, 2006
    #14
  15. So it's only leaders that you don't want to change?
     
    Michael Bulatovich, Dec 21, 2006
    #15
  16. Brian W.

    Brian W. Guest

    Precisely!

     
    Brian W., Dec 21, 2006
    #16
  17. I thought you already had that problem licked with the code you posted.
     
    Michael Bulatovich, Dec 21, 2006
    #17
  18. Brian W.

    Brian W. Guest

    Quote:
    ---When I use this function:

    (sssetfirst nil (ssget "_X" '((0 . "DIMENSION"))))
    (princ)

    All of the dimensions in a drawing are selected and put a set. From
    there I can use the properties within AutoCad to change the Arrow1 and
    Arrow2 properties. The scale, color, etc remains unchanged and the
    ticks are the correct size for each individual dimension. Is there a
    way within lisp to change the Arrow1 and Arrow2 properties?---

    Basically, I can select all of the dimensions within lisp. Then the
    user has to manually alter the Arrow1 and Arrow2 properties within
    AutoCad. The question is how do you change the Arrow1 and Arrow2
    properties within lisp so it acts the same as when the user does it
    within AutoCad?

    Thanks again,
    Brian W.
     
    Brian W., Dec 21, 2006
    #18
  19. Don't know. Consult your version's documentation.
     
    Michael Bulatovich, Dec 22, 2006
    #19
  20. Brian W.

    ddpcad Guest

    busy tonight?
    :)
     
    ddpcad, Dec 22, 2006
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.