rename problem..

Discussion in 'AutoCAD' started by C Witt, Jul 28, 2003.

  1. C Witt

    C Witt Guest

    OK, the situation:

    I have 2 dimension styles.. "A" & "B"..

    (Keep in mind this has to be done via lisp)

    Both styles are in use, so can't be purged..
    I want to rename "A" to "B".. but as "B" already exists, I can't. So
    the question.. How do I "move" the dim's on style "A".. to style "B"..
    via lisp (no user input)..
     
    C Witt, Jul 28, 2003
    #1
  2. C Witt

    Mark Propst Guest

    Rename b temp
    purge b
    rename a b
    purge a
    rename temp a
    ?
     
    Mark Propst, Jul 28, 2003
    #2
  3. C Witt

    Tom Berger Guest

    You can use my SSMOD function (see below) to modify the DXF value for
    the dimstyle of selected dimensions.

    To select dimensions of style "A" use
    (setq sset (SSGET "X" '((0 . "DIMENSION") (3 . "A"))))

    To modify the selection use
    (SSMOD sset 3 "A")

    You can use SSMOD to modify any other dxf value of the selected
    entities, i.e. (ssmod (ssget) 8 "NEWLAYER") moves all selected
    entities to layer "NEWLAYER".

    Tom Berger

    ;;;; LISP STARTS HERE ->

    ;;; SSMOD changes DXF values of AutoCAD drawing entities
    ;;; usage: (ssmod <selection set> dxf-code new-value
    ;;;
    ;;; (ssmod (ssget) 8 "NEWLAYER") moves the selected entities to
    ;;; layeer NEWLAYER
    ;;; (ssmod (ssget '((0 . "INSERTION"))) 2 "NEWBLOCKREF") changes
    ;;; the references for selected block insertions to "NEWBLOCKREF"
    ;;; (ssmod (ssget '((0 . "INSERTION"))) 10 '(0 0 0)) changes
    ;;; the insertion point for selected block insertions to 0,0,0
    ;;;
    ;;; (c) Tom Berger 1994
    ;;; free to be used by everybody
    ;;;


    (defun ssmod (ss dxf val)
    (mapent '(lambda (ename)
    (ssmodent ename dxf val)
    )
    ss
    )
    )


    (defun mapent (fun ss / i)
    (repeat (setq i (sslength ss))
    ((lambda (proc args / ss fun i)
    (apply
    proc
    args
    )
    )
    fun
    (list (ssname ss (setq i (1- i))))
    )
    )
    )


    (defun ssmodent (ename dxf val / old)
    (if (setq old (assoc dxf (entget ename)))
    (entmod (subst
    (cons dxf val)
    old
    (entget ename)
    )
    )
    (entmod (cons (cons dxf val) (entget ename)))
    )
    )

    ;;;; <- LISP ENDS HERE
     
    Tom Berger, Jul 28, 2003
    #3
  4. C Witt

    C Witt Guest

    nope.. I have data on both..and they are the "same" styles just with
    diff names.. I want them both on one style name.. (what i'm after is a
    layer merge for dimensions, but done all with lisp)
     
    C Witt, Jul 28, 2003
    #4
  5. Without a lisp routine (just to get this done) you could
    wblock all the dimensions of style "A" into a new file.
    Open the file, rename "A" to "B" then reinsert that file
    into the original drawing.
     
    Jason Piercey, Jul 28, 2003
    #5
  6. Is there a problem with updating them as Doug suggests?
     
    Jason Piercey, Jul 28, 2003
    #6
  7. C Witt

    C Witt Guest

    Yes, and No.. It would work.. but it would require user input.. i'm
    hoping for a All lisp solution.. (we just finished looking at the
    selection filter, but we shocked to see it allows for leaders.. but not
    dimensions)
     
    C Witt, Jul 28, 2003
    #7
  8. C Witt

    Jason Wilder Guest

    Keep in mind, this is based on what knowledge I have of working with Dims
    via LISP. Doug's approach may prove to be the most straightforward, you'd
    just have to create a selection set of your 'B' style dims and then
    DIMUPDATE them as 'A' by making sure it's current. Keep in mind, once a
    dimension is created under a style that has user modifications, then the
    style name will actually be (3 . "B$0"). So you'll have to do a string
    match for that assoc code.

    Some of the dimensions may not 'carry-over' properly or correctly and you'll
    still need to do a check on them, but this method should quickly eliminate
    there being 2 styles.
     
    Jason Wilder, Jul 28, 2003
    #8
  9. C Witt

    David Kozina Guest

    I could be wrong on this but if you have SuperPurge from Manusoft, **if you
    set Dimstyle "B" current**, then you can do a hard purge of Dimstyle "A"
    whereupon all existing style A's dimensions will be sent to B.

    I know this works for layers, so I suspect it may work for dimstyles, too.

    And since SuperPurge has an API and can be called via the command line, you
    should be able to use it in a LISP routine.

    hth,
    David Kozina
     
    David Kozina, Jul 28, 2003
    #9
  10. C Witt

    C Witt Guest

    What/were is it.. and what does it cost?

     
    C Witt, Jul 28, 2003
    #10
  11. C Witt

    C Witt Guest

    and HOW would i do a string search?.. (novice @ lisp)
     
    C Witt, Jul 28, 2003
    #11
  12. C Witt

    Joe Becker Guest

    As I understand it this is what you want.
    Substitue in the correct dimension name (this will not work for leaders
    however because of a flaw with ssget and leader dimension styles, but it can
    be modified to do so if necessary)

    (defun c:DIMCHANGE ()
    (setq DIMTOCHANGE "A")
    (setq NEWDIM "B")
    (setq E (ssget "X" (list (cons 3 DIMTOCHANGE))))
    (setq COUNT 0)
    (setq EN (ssname E COUNT))
    (setq EL (entget EN))
    (WHILE (/= EN nil)
    (setq EL (entget EN))
    (setq EL (subst (cons 3 NEWDIM) (assoc 3 EL) EL))
    (entmod EL)
    (entupd EN)
    (setq COUNT (1+ COUNT))
    (setq EN (SSNAME E COUNT))
    )
    (princ "\nObjects successfully modified!")(princ)
    )

    Joe Becker
     
    Joe Becker, Jul 28, 2003
    #12
  13. C Witt

    Joe Becker Guest

    (setq E (ssget "X" (list (cons -4 "<OR")(cons 3 DIMTOCHANGE)(cons 0
    "LEADER")(cons -4 "OR>"))))

    change the (setq E ... line to the above to select leaders as well

    Joe Becker
     
    Joe Becker, Jul 28, 2003
    #13
  14. C Witt

    C Witt Guest

    well that works great, thank you.

    just one more question.. you said it could be tweeked to work on
    leaders.. care to share the "how" ? ;>

    Thanks!
     
    C Witt, Jul 28, 2003
    #14
  15. C Witt

    C Witt Guest

    oopss.. never mind.. didn't see the new posts ;P
     
    C Witt, Jul 28, 2003
    #15
  16. C Witt

    C Witt Guest

    will the wildcard work in lisp?

     
    C Witt, Jul 28, 2003
    #16
  17. C Witt

    Joe Becker Guest

    You need to consider what Jason Wilder said as well...
    you might want to use A* as the dimension name to make sure that you get all
    variations of dimension style A. It is not necessary on B because that is
    what you are changing to.

    This function really only has two main parts: getting the objects to change
    with ssget and doing entity modification with subst and entmod. The while
    loop is used to change all of the objects in the selection set one after
    another. These standard autocad functions are fairly well explained in the
    help.

    I guess your next step is to create a script to run this command for all of
    your details.

    Joe Becker
     
    Joe Becker, Jul 28, 2003
    #17
  18. C Witt

    Joe Becker Guest

    Yes, you can use wildcards (not in all instances but most I believe).
     
    Joe Becker, Jul 28, 2003
    #18
  19. C Witt

    C Witt Guest

    We have come accross a problem with the script.. the section that calls
    up leaders.. calls up ALL leaders.. regardless of what style they are
    on.. and thus that section can't be used in our lisp..

    So.. one last question.. do you know of a way to access the properties
    "selection filter" via command line?.. or is it only avail via the
    window? (I ask becuase it has a great leader selection tool).

    thanks.
     
    C Witt, Jul 29, 2003
    #19
  20. C Witt

    C Witt Guest

    Jason,

    A question..

    Where Do I put the "target" dimstyle name? (if "name" is the existing)
     
    C Witt, Jul 30, 2003
    #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.