Handle Object Events

Handle Object Events

Yehoshua18
Enthusiast Enthusiast
363 Views
3 Replies
Message 1 of 4

Handle Object Events

Yehoshua18
Enthusiast
Enthusiast

How do I work with Object Handling Events?

 

I've created labels for Feature Lines using C# which are not available in Civil 3d. But I'd like to update those labeles if that feature line is modified in the future, without the user having to rerun the command. Anyone have any examples of this? 

 

This is all I've got so far, and it's not been very helpful. 

 

Thanks for the help!

- Josh

0 Likes
364 Views
3 Replies
Replies (3)
Message 2 of 4

norman.yuan
Mentor
Mentor

It would depend on what the said label is and how you create it. You need to provide more details/show relevant code, especially how the label and the feature line is connected/linked to each other in some way (or not at all, for that matter).

 

You can handle DBObject.Modified event, Database.ObjectModified event, or even other events at Document level (CommandWillStart/Ended, DocumentLockModeChanged... Again, depending on the situations you did not provide. You might also to consider Overrule for tight/thorough control of the 2 entities being coupled.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 4

Jeff_M
Consultant
Consultant

THIS may be of interest to you. I know it helped Sinc and myself.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 4 of 4

Yehoshua18
Enthusiast
Enthusiast

Wow, pretty cool! I'll be sure to use that in the future. 

 

I found a way to do what I wanted by creating an event Handler which deletes the old custom label and redraws it if the featureline is modified in any way (elevation points, PVI points ect..). My problem before was that I did not understand how Event Handles worked. 

 

What happens is that this line of code "fline.Modified += new EventHandler(flinemod);" Creates a persistent event handle which exists beyond the execution of the current block of code. When the event is triggered it casts the object into a separate method flinemod() which will start spontaneously with the input of the sender object, and event arguments. Still don't understand the event arguments. I also needed to send the flinemod() some other objects along with the sender object, but this event handler object only accepts the Sender Object and Event Arguments. I could not figure out what Even Arguments are in the context of AutoCad, I wanted to see if I could imbed the objects I wanted to cast to flinemod() inside the Event Arguments, but I failed. 

 

I figured out a workaround, but if someone could explain the Event Arguments to me I would be grateful! 


Thanks!

0 Likes