TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: T.Willey on October 19, 2006, 01:56:38 PM

Title: How would one get the Vertex Object?
Post by: T.Willey on October 19, 2006, 01:56:38 PM
I mean how can one step through an AcDb2dPolyline to get the vertex objects?  I know you can do it with enames and entnext, but is there way way with straight ActiveX controls?  Question just popped into my head, and I didn't have/find an answer.

Thanks.
Title: Re: How would one get the Vertex Object?
Post by: MP on October 19, 2006, 02:20:49 PM
Mnimal / brute force / concept code --

Code: [Select]
(defun foo ( document 2dPlineObject / result )
    (   
        (lambda ( objectID )
            (while
                (eq "AcDb2dVertex"
                    (vla-get-objectname
                        (setq object
                            (vla-objectidtoobject
                                document
                                objectID
                            )
                        )
                    )
                )
                (setq
                    result   (cons object result)
                    objectID (+ 8 objectID)
                )
            )
        )       
        (+ 8 (vla-get-objectID 2dPlineObject))
    )
    (reverse result)
)

:)
Title: Re: How would one get the Vertex Object?
Post by: MP on October 19, 2006, 02:22:31 PM
<not compatible with object dbx because of the vla-objectidtoobject call which works strictly in an active document context>
Title: Re: How would one get the Vertex Object?
Post by: T.Willey on October 19, 2006, 02:29:21 PM
Is the the same way 'entnext' works?  Finds the code (hex?) of the object, and then adds one (8 because of hex number system) number to it?  Very interesting.  I would never have thought of doing it this way.
Title: Re: How would one get the Vertex Object?
Post by: MP on October 19, 2006, 02:33:13 PM
Is the the same way 'entnext' works?

Kinda, insomuch as they are sequential entiies / objects.

Finds the code (hex?) of the object, and then adds one (8 because of hex number system) number to it?

No, nothing to do with hex. Just my observataion that ObjectIDs are issued as a multiple of 8.

Caution -- not tried against polylines with modified / deleted vertices -- driver beware.

:)
Title: Re: How would one get the Vertex Object?
Post by: T.Willey on October 19, 2006, 02:37:48 PM
Thanks again Michael.  I think this must be the only way.  I was hoping there was something simple I missed, like (vlax-invoke BlkObj 'GetAttributes), but for polylines.
Title: Re: How would one get the Vertex Object?
Post by: MP on October 19, 2006, 02:39:36 PM
My pleasure. I think it more of a demonstration of the <cough> complete object model Autodesk authored.

:)