best way to add handler to an autocad object in database (no code question)

best way to add handler to an autocad object in database (no code question)

Anonymous
Not applicable
1,099 Views
3 Replies
Message 1 of 4

best way to add handler to an autocad object in database (no code question)

Anonymous
Not applicable

what is the best way of getting (modified) event triggered for some specific object?

i see a lot of examples doing: if database is modified, then trigger event, then iterate our list to if that object is in it.

is that the better that way, like to add handler to the specific object, and then when each of them is modified, then each of them call handler?

 

thank you!

0 Likes
1,100 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

HI there,

 

There is no realy a simple awnser to your question. It will denpend on wat you want to do with the event handler. Of you want to use an autocad transaction then create a list and handle the commandended event handler. If you wat to do some thing else u can use the object event attached to that element.

 

KInd regards,

 

Irvin

0 Likes
Message 3 of 4

arcticad
Advisor
Advisor

You can also "tag" your object by using an Xrecord and then using the general events to check the item. This may be more useful if you want the event to persist over multiple drawings and sessions. Otherwise you will have to initialize the objects events each time the drawing is opened.

---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 4 of 4

Anonymous
Not applicable

i can write xrecord to my object, i have used it like this, and i had document object modified event

doing:

-open object with trans

-if xrec is my

-if the data is what is interested

-do things

 

i did it like this, like you said - when i had to use same file over and over again...

1) it is one way i did it, because i did not know for better.

2) the other way i know is - to have a list of my objects, global obj.modified handler, and do "if my list contains object that is modifyed"

3) and the third way (wich i'm trying to play with now) is - to add event handler to EACH object individualy...

 

am i right?

i'm an amater in this, so appologise if you dont understand me 🙂

i'm not sure wich one is recommended, as it seems to me that if one would add and remove handlers for example, for each user selection change, autocad will not like it?

 

and if i do use 3), what happens if i use custom .net object with constructor to add handler from objectid, and destructor to remove?

because, i'm not sure when will garbage collector start destructors (will it happen after dwg database is destroyed)

 

maybe to much questions in single message? 🙂

 

0 Likes