rename problem..

C Witt

Usenet Archive
Joined
Jun 23, 2003
Messages
396
Reaction score
0
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)..
 
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)..

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
 
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)
 
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.
 
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)
 
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.
 
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
 
What/were is it.. and what does it cost?

David said:
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
 
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
 
(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
 
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!
 
will the wildcard work in lisp?

Joe said:
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
 
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
 
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.
 
Jason,

A question..

Where Do I put the "target" dimstyle name? (if "name" is the existing)
 

Latest threads

Back
Top