TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jmaeding on August 08, 2006, 05:46:03 PM

Title: getting object "above" with from draworder
Post by: jmaeding on August 08, 2006, 05:46:03 PM
(Posted in adesk customization group also)
I want to replace an existing entity with another, and put the new one at the exact same draworder.
To get the draworder of the existing entity, I have to use the getfulldraworder method I believe.
Once I have the list, I can determine what object is above me so I use that in the MoveBelow method.
I am this far with getting it:

(setq space (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
(setq extdict (vla-getextensiondictionary space))
(if (not (zerop (vla-get-count extdict)))
  (setq sorttbl (vla-getobject extdict "acad_sortents"))
  (setq sorttbl (vla-addobject extdict "acad_sortents" "acdbsortentstable"))
)
(setq allorder (vla-getfulldraworder sorttbl space :vlax-false))

but no go, I get nil for allorder...any ideas
Title: Re: getting object "above" with from draworder
Post by: T.Willey on August 08, 2006, 05:57:28 PM
I just noticed that the SortEntsDictionary has a SwapMember method.  If you have the entity names, then you can swap them, no need to find the full order (which I haven't been able to do either).
Quote from: Acad Help
SwapOrder Method
 


Swaps the draw order positions of two objects.

See Also | Example

Signature

object.SwapOrder (Object1, Object2)

object

SortentsTable
The object or objects this method applies to.

Object1

AcadEntity; the first object.

Object2

AcadEntity; the second object.
Title: Re: getting object "above" with from draworder
Post by: T.Willey on August 08, 2006, 06:03:06 PM
It worked for me.  I drew a line, and then a rectangle, and then I hatched the rectangle.  I used the draw order command, and brought it all to front.  The hatch still on top.  I got the object id for the line, and the hatch.  I swaped them in the dictionary, and after a regen the line shows over the hatch.

Hope that helps.
Title: Re: getting object "above" with from draworder
Post by: Jeff_M on August 08, 2006, 06:38:24 PM
(setq allorder (vla-getfulldraworder sorttbl space :vlax-false))

but no go, I get nil for allorder...any ideas
Yep, this is one of those cases where the supplied argument (you used space above) is an OUTPUT variable.....this is more what you want:
Code: [Select]
(vla-getfulldraworder sorttbl 'allorder :vlax-false)
(setq allList (vlax-safearray->list allorder))
Title: Re: getting object "above" with from draworder
Post by: T.Willey on August 08, 2006, 06:42:24 PM
(setq allorder (vla-getfulldraworder sorttbl space :vlax-false))

but no go, I get nil for allorder...any ideas
Yep, this is one of those cases where the supplied argument (you used space above) is an OUTPUT variable.....this is more what you want:
Code: [Select]
(vla-getfulldraworder sorttbl 'allorder :vlax-false)
(setq allList (vlax-safearray->list allorder))
Good one Jeff.  I don't know if I would have ever caught that one.
Title: Re: getting object "above" with from draworder
Post by: jmaeding on August 08, 2006, 08:37:43 PM
ahhh, grasshoppper!
Thanks again, hope you make it to AU this year!