Keeping ObjectId reference in an Autocad .Net WCF plugin

Keeping ObjectId reference in an Autocad .Net WCF plugin

Anonymous
Not applicable
1,012 Views
2 Replies
Message 1 of 3

Keeping ObjectId reference in an Autocad .Net WCF plugin

Anonymous
Not applicable

There is a .Net Autocad plugin in which a WCF service is used to call a method on another process external to Autocad. Autocad entities are wrapped in custom classes and passed through WCF. Once the call returns the plug-in needs to write the result back into Autocad database.

 

Here is the problem: ObjectId is needed to fetch the object and write the result back; WCF serialize the data and ObjectId is not serializable. So I don't have access to the object.

 

Is there any workaround/solution for this?

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

Norman_Yuan
Mentor
Mentor

ObjectId is only meaningful in current AutoCAD session (where your plug-in runs). So, I cannot imagine why you need to pass it to an external process, which relies on it to fetch data (from the same AutoCAd session where the ObjectId is originated, if so, then, why external process)?

 

With that said, if you do need some kind of identification of an Entity being passed out to somewhere, and need the data being passed as Serializable, you can pass entity's Handle as string value, which can be persisted between AutoCAd sessions.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks for your reply. Appology for my poor explanation. The external app does nothing with the ObjectId. It's only supposed to be used by the time the calculation on the external app is finished and the control is back to the plugin to write the result. The thing is the plugin wraps some Autocad polylines in a custom type and puts the ObjectId of the poly inside that custom type, so that it be used for writing the result.

 

I am aware of using Handle.Value which is of type long and to use it to get the ObjectId. But what is the performance of this on large number of calls?

What does the GetObjectId via handle work? does it create new objectId or search for it on the database?

0 Likes