Discussion:
using entmod to change dimension style
(too old to reply)
Z1000
2004-01-06 22:04:09 UTC
Permalink
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)
Mark Propst
2004-01-06 22:20:36 UTC
Permalink
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)
Post by Z1000
I am trying to create a lisp that will update associative dimensions on
older drawings to a new client standard.
Moshe Avraham
2004-01-06 22:11:01 UTC
Permalink
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
Post by Z1000
I am trying to create a lisp that will update associative dimensions on
older drawings to a new client standard.
Post by Z1000
I set up the new style called "style_new" and tried to change all the old
"style_old" dimensions to "style_new".
Post by Z1000
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.
Post by Z1000
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!
Post by Z1000
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.
Post by Z1000
Anyone solved this or want to try? Please?
Mike (Z1000)
Jason Piercey
2004-01-07 16:36:42 UTC
Permalink
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
Member of the Autodesk Discussion Forum Moderator Program
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.
Steve Doman
2004-01-08 02:10:12 UTC
Permalink
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
Post by Jason Piercey
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
; [object] - vla-object, dimension object
; [styleName] - string, new stylename
; return: nil or error message
; (putDimstyleName (vlax-ename->vla-object (car (entsel))) "myNewStyle")
Jason Piercey
2004-01-08 04:12:58 UTC
Permalink
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
Member of the Autodesk Discussion Forum Moderator Program
Post by Steve Doman
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
Jason Piercey
2004-01-08 04:14:51 UTC
Permalink
oops.... looks like I stuttered...
--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
Post by Jason Piercey
(vla-getxdata obj "acad" 'values 'types)
nil
(vla-getxdata obj "acad" 'values 'types)
nil
Steve Doman
2004-01-08 14:26:19 UTC
Permalink
Jason,

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

Regards,
Steve Doman
Post by Jason Piercey
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
Member of the Autodesk Discussion Forum Moderator Program
Post by Steve Doman
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
Jason Piercey
2004-01-08 14:34:38 UTC
Permalink
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
Member of the Autodesk Discussion Forum Moderator Program
Post by Steve Doman
Jason,
Thanks for the explanation! That's way cool. I've got to play around with
Xdata some time.
Regards,
Steve Doman
Z1000
2004-01-08 17:13:13 UTC
Permalink
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)
Post by Jason Piercey
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
; [object] - vla-object, dimension object
; [styleName] - string, new stylename
; return: nil or error message
; (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
Member of the Autodesk Discussion Forum Moderator Program
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.
Jason Piercey
2004-01-08 17:28:52 UTC
Permalink
Glad I could help.
--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
Post by Z1000
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)
Michael
2004-01-07 16:06:53 UTC
Permalink
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???
Mike,
Here's a little routine called Dsako which I wrote back in R14. Just did
a
little update to it tonight so hope I didn't introduce any new bugs.
Give
it a whirl and let me know if it works for you!
Before running this routine, setup your new dimstyle just the way you want
it. Make that new dimstyle the current dimstyle. Run the routine and
select dimensions and leaders. Hopefully it will work. I can tune it up
if
necessary.
Regards,
Steve Doman
Post by Z1000
I am trying to create a lisp that will update associative dimensions on
older drawings to a new client standard.
Post by Z1000
I set up the new style called "style_new" and tried to change all the
old
"style_old" dimensions to "style_new".
Post by Z1000
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.
Post by Z1000
I need a way to change the dimension style without altering the
"overrides".
Post by Z1000
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!
Post by Z1000
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.
Post by Z1000
Anyone solved this or want to try? Please?
Mike (Z1000)
Steve Doman
2004-01-09 03:47:41 UTC
Permalink
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
Mike,
Found the bug, thanks. I haven't used this routine for a few years and
had
forgotten that AutoDesk changed some things inside the dimstyle entget
list.
<clip>
Z1000
2004-01-09 17:01:17 UTC
Permalink
I got it - version 2.05. Thanks a bunch Steve. Maybe I can help you out
sometime.

Mike (Z1000)
Post by Steve Doman
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
Mike,
Found the bug, thanks. I haven't used this routine for a few years and
had
forgotten that AutoDesk changed some things inside the dimstyle entget
list.
<clip>
Steve Doman
2004-01-10 19:59:21 UTC
Permalink
You're welcomed!

Steve
Post by Z1000
I got it - version 2.05. Thanks a bunch Steve. Maybe I can help you out
sometime.
Mike (Z1000)
bgriesel
2004-01-08 16:46:04 UTC
Permalink
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)
Z1000
2004-01-08 18:34:54 UTC
Permalink
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))
)
)
)
Post by bgriesel
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".
Post by bgriesel
(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
2004-01-08 18:50:25 UTC
Permalink
Glad I could help.
Don't you just love these Discussion groups? Had a problem of my own solved here ealier today.

Bernie
Loading...