Editor.GetEntity - but with multiple documents

Editor.GetEntity - but with multiple documents

danielmollerX5W2N
Contributor Contributor
200 Views
2 Replies
Message 1 of 3

Editor.GetEntity - but with multiple documents

danielmollerX5W2N
Contributor
Contributor

I need to make a .NET command that allows the user to pick one entity from two documents.   

 

Flow:

- User types command name (this is ok, can be done with a [CommandMethod(...)] )

- User is prompted to select an entity from the active document (this is ok, with Editor.GetEntity)  

- User is prompted to select another entity from another document that is open (user picks the document and entity - Need help here!)

 

How can this be achieved?

0 Likes
201 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor

One of changes when Acad2015 introduced that broke many existing existing custom AutoCAD code (LISP/VBA/.NET...) was that the active command would be cancelled if the current drawing is changed. I had some code back then that required user to go to other opened drawing to select entity/point and then shift back to continue. The code worked well until Acad2015, and workaround was required and worked out. I wrote about this here:

 

https://drive-cad-with-code.blogspot.com/2017/04/asking-user-to-select-entity-in-other.html 

https://drive-cad-with-code.blogspot.com/2017/04/asking-user-to-select-entity-in-other_4.html 

 

HTH.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3

ActivistInvestor
Mentor
Mentor

You have to add the CommandFlags. Session flag to your CommandMethod attribute so that the command runs in the application context. Then you can change the active document after the user picks the first entity to the document that contains the second entity. In order to interact with any document from the application context command you must lock the document.