using entmod to change dimension style

Discussion in 'AutoCAD' started by Z1000, Jan 6, 2004.

  1. Z1000

    Z1000 Guest

    I am trying to create a lisp that will update associative dimensions on older drawings to a new client standard.

    I set up the new style called "style_new" and tried to change all the old "style_old" dimensions to "style_new".

    I tried setting "style_new" as my current dimension style and using the "update" command. Problem with that was that it kills any "overrides" that might exist on the dimensions such as DIMLFAC or DIMSE1, etc.

    I need a way to change the dimension style without altering the "overrides".

    I tried using SSGET to make a selection set SS1 out of the offending dimensions and use (command "-DIMSTYLE" "A" SS1 "") to change them to the current style. It works, but it also resets the "overrides". Aaaagh!

    I then tried using SUBST and ENTMOD to change (3 . "style_old") to (3 . "style_new") but it does not work on dimensions apparently. It will change the entity data, but as soon as you ENTMOD it, it returns to the original style.

    Anyone solved this or want to try? Please?

    Mike (Z1000)
     
    Z1000, Jan 6, 2004
    #1
  2. Hi

    You can read and save the dimension overrides aside then apply the new
    dimension style on the dimension object then apply back the dimension
    overrides.

    good luck
    moshe


    older drawings to a new client standard.
    "style_old" dimensions to "style_new".
    "update" command. Problem with that was that it kills any "overrides" that
    might exist on the dimensions such as DIMLFAC or DIMSE1, etc.
    dimensions and use (command "-DIMSTYLE" "A" SS1 "") to change them to the
    current style. It works, but it also resets the "overrides". Aaaagh!
    "style_new") but it does not work on dimensions apparently. It will change
    the entity data, but as soon as you ENTMOD it, it returns to the original
    style.
     
    Moshe Avraham, Jan 6, 2004
    #2
  3. Z1000

    Mark Propst Guest

    sounds like you need to collect your dims in a sel set, step through each
    dim, get it's overrides, change the stylename, then reapply the overrides
    (stored in xdata on the dim ent)
    unless maybe vla methods of setting the styleName property might work?
    (rather than entmod)

    older drawings to a new client standard.
     
    Mark Propst, Jan 6, 2004
    #3
  4. Z1000

    Michael Guest

    Steve, I tried your routine, but I get an error message:

    Error: bad argument type: numberp: nil

    I might be able to use some of the code however. I need to figure out how
    to extract the override info and save it and then re-apply it after updating
    to the new style.

    Thanks for you hard work.

    Mike (Z1000)

    P.S. is the AutoDesk forum REALLY slow, or is it just my computer???
     
    Michael, Jan 7, 2004
    #4
  5. I been meaning to write a dimension merge routine for
    a while now. Started to do this last night but don't have
    the time right now to finish it up. I'll offer one of the
    functions from my attempt, maybe it will help you.


    ; Jason Piercey . January 6th, 2004
    ; function to redefine the styleName property
    ; of a dimension object and retain any overrides
    ; that have been applied
    ; Arguments:
    ; [object] - vla-object, dimension object
    ; [styleName] - string, new stylename
    ; return: nil or error message
    ; example:
    ; (putDimstyleName (vlax-ename->vla-object (car (entsel))) "myNewStyle")

    (defun putDimstyleName (object styleName / values types name child res)
    (vla-getxdata object "acad" 'values 'types)

    ;; determine if [object]'s styleName
    ;; property is that of a child style,
    ;; if so test for existence of same
    ;; child style defined by [styleName]
    (if
    (and
    (wcmatch (setq name (vla-get-styleName object)) "*`$#")
    (not
    (vl-catch-all-error-p
    (vl-catch-all-apply
    '(lambda ()
    (vla-item
    (vla-get-dimstyles
    (vla-get-activedocument
    (vlax-get-acad-object)))
    (setq
    child
    (strcat
    styleName
    (substr
    name
    (1- (strlen name))
    (strlen name)
    )
    )
    )
    )
    )
    )
    )
    )
    )
    (setq styleName child)
    )

    (setq
    res
    (vl-catch-all-apply
    'vla-put-styleName
    (list object styleName)
    )
    )

    (if (vl-catch-all-error-p res)
    (vl-catch-all-error-message res)
    (if (and values types)
    (vla-setxdata object values types)
    )
    )
    )
     
    Jason Piercey, Jan 7, 2004
    #5
  6. Z1000

    Steve Doman Guest

    Jason,

    Nice function. I am able to follow your thinking except for the xdata
    stuff. I haven't much experience with Xdata, perhaps you could enlighten
    me. What is the purpose of your vla-setxdata line? I would think that it
    would be sufficient to just vla-put-stylename.

    Thanks!

    Regards,
    Steve Doman
     
    Steve Doman, Jan 8, 2004
    #6
  7. Hi Steve,

    I'm no xdata expert, but in my brief testing just using
    (vla-put-stylename) removed any existing overrides.
    So I found it necessary to save any existing values,
    and restore them after applying the new stylename.


    (setq obj (vlax-ename->vla-object (car (entsel))))
    #<VLA-OBJECT IAcadDimRotated 056f8ce4>

    (vla-get-stylename obj)
    "Standard"

    (vla-getxdata obj "acad" 'values 'types)
    nil

    !values
    #<safearray...>

    !types
    #<safearray...>


    (vla-put-stylename obj "test")
    nil

    (vla-getxdata obj "acad" 'values 'types)
    nil

    (vla-getxdata obj "acad" 'values 'types)
    nil

    !values
    nil

    !types
    nil
     
    Jason Piercey, Jan 8, 2004
    #7
  8. oops.... looks like I stuttered...
     
    Jason Piercey, Jan 8, 2004
    #8
  9. Z1000

    Steve Doman Guest

    Jason,

    Thanks for the explanation! That's way cool. I've got to play around with
    Xdata some time.

    Regards,
    Steve Doman
     
    Steve Doman, Jan 8, 2004
    #9
  10. I've been leery of xdata in the past as those association
    lists looked like a pain to deal with but the ActiveX
    methods sure seemed like a breeze.
     
    Jason Piercey, Jan 8, 2004
    #10
  11. Z1000

    bgriesel Guest

    Here is one I have made, it is for an individual entity selection. It does not change any override that I have concerns for, such as scale and tolerance overrides. Try it, Perhaps it might work or be adaptable for you, keep in mind or couirse, you will have to edit in your DIMSTYLE name to replace my "Fractional".

    (defun C:FRAC()
    (setq DPRES nil
    OBJ Nil)
    (if (= nil (tblsearch "dimstyle" "FRACTIONAL"))
    (progn (alert "No DimStyle named Frational")(exit)(prin1))
    )
    (while (= nil DPRES)
    (while (= nil OBJ)(setq OBJ (entsel "\n Select Dimension")))
    (setq NM (car OBJ))
    (setq D (entget NM))
    (if (= "DIMENSION" (cdr (assoc 0 D)))
    (setq DPRES T)
    (setq OBJ nil)
    )
    )
    (setq D (subst '(3 . "FRACTIONAL")
    (assoc 3 D)
    D
    )
    )
    (entmod D)
    (entupd NM)
    (prin1)
    )(prin1)
     
    bgriesel, Jan 8, 2004
    #11
  12. Z1000

    Z1000 Guest

    Well, thanks Jason. The function works, but now I am encountering problems
    with the two styles having different dimscales or DIMLFAC settings, so they
    don't show up as overrides. I will have to work those issues out, but that
    function does exactly what I wanted it to do. I don't know how or why it
    works however as I don't recognize much of the code. I am old school lisp
    and that stuff is all newfangled. Thanks again.

    Mike (Z1000)

     
    Z1000, Jan 8, 2004
    #12
  13. Glad I could help.
     
    Jason Piercey, Jan 8, 2004
    #13
  14. Z1000

    Z1000 Guest

    bgriesel, thank you thank you. Your routine was very similar to the one I
    wrote below, but yours worked. After reviewing yours, I figured out what I
    had done wrong. I noted the change I did it the code below. Thanks again,
    it works wonderfully and simply.

    Mike (Z1000)

    ;;; Routine to change dimension style OLD_STYLE to NEW_STYLE
    (setq SS1 nil)

    (setq SS1 (ssget "X" '((0 . "DIMENSION") (3 . "OLD_STYLE"))))

    (if SS1
    (progn
    (setq CT 0)
    (repeat (sslength SS1)
    (setq ED (entget (ssname SS1 CT)))
    ;;; I had the next line as (subst '(3 . "NEW_STYLE") (assoc 3 ED)
    ED)
    ;;; it did not work because I did not define ED as the updated data
    (setq ED (subst '(3 . "NEW_STYLE") (assoc 3 ED) ED))
    (entmod ED)
    (setq CT (1+ CT))
    )
    )
    )

    not change any override that I have concerns for, such as scale and
    tolerance overrides. Try it, Perhaps it might work or be adaptable for you,
    keep in mind or couirse, you will have to edit in your DIMSTYLE name to
    replace my "Fractional".
     
    Z1000, Jan 8, 2004
    #14
  15. Z1000

    bgriesel Guest

    Glad I could help.
    Don't you just love these Discussion groups? Had a problem of my own solved here ealier today.

    Bernie
     
    bgriesel, Jan 8, 2004
    #15
  16. Z1000

    Steve Doman Guest

    Mike,

    Didn't see a reply so wasn't sure if you noticed that I attached the fixed
    version to my prior post.

    Steve Doman


    <clip>
     
    Steve Doman, Jan 9, 2004
    #16
  17. Z1000

    Z1000 Guest

    I got it - version 2.05. Thanks a bunch Steve. Maybe I can help you out
    sometime.

    Mike (Z1000)
     
    Z1000, Jan 9, 2004
    #17
  18. Z1000

    Steve Doman Guest

    You're welcomed!

    Steve
     
    Steve Doman, Jan 10, 2004
    #18
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.