Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Convert ObjectID to Handle

2 REPLIES 2
Reply
Message 1 of 3
JEdwardL
552 Views, 2 Replies

Convert ObjectID to Handle

It looks like I might have programmed myself into a corner again!

 

I wrote code for an application that stores links to lines and blocks in dictionaries using handles.  The routines work well and I can manipulate the data marvelously, but if one of the lines or blocks get erased the whole danged opera falls apart.  I knew this when I wrote the routines and have always been careful about using the ERASE command, as a matter of fact, I considered disabling it.

 

I am trying to make the package more robust.  I have been experimenting with attaching a reactor (:vlr-erased) to the objects which fires when the object is erased.  Unfortunately it fires before I can retrieve the handle of the object so that I can remove the references from the dictionaries.  The only thing that I can retrieve once ERASE fires is the ObjectID.  I can't seem to find a Visual Lisp routine to convert this value to a handle, does one exist?  Is there an ObjectID collection that has any references in it?

 

I found several threads on the subject in different discussion groups, but none offered any acceptable solutions.

 

Thank you for any help you can give.

 

J Leavitt

 

 

2 REPLIES 2
Message 2 of 3
Lee_Mac
in reply to: JEdwardL

(defun IDtoHandle ( doc id )
    (vla-get-handle (vla-objectidtoobject doc id))
)

 

Though, although I haven't seen the application, I have a distinct feeling that you are over complicating things - surely you can just add some error trapping in the form of a conditional testing whether an object / entity has been erased? [vlax-erased-p / (entget <entity>) ]

Message 3 of 3
stevor
in reply to: JEdwardL

Applying LeeMac's method:

 (if (entget entname )

   (progn ; do your thing

 

Or, with other tests:

 (if (and entname (entget entname)

              ... other tests

     )

  (progn ...

 

Done all the time for previously selected or named objects.

Also, sometimes the data type of the variable 'entname,'

or whatever variable name used,

must be differentiated between 'ENAME and 'VLA-OBJECT.

 

S

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost