.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Save selected objects for later use

6 REPLIES 6
Reply
Message 1 of 7
greg
468 Views, 6 Replies

Save selected objects for later use

Is there any way to have a user select entities and then save that selection for later use not only in the current drawing session but also for later retrieval in another completely new session and even by someone else?  I anticipate the need to save the data out to an external file/database but I am not sure what to save out as I believ the object ids are session dependent.

 

Any thoughts/ideas/directions are welcome.

 

Thanks in advance.

6 REPLIES 6
Message 2 of 7
jeff
in reply to: greg

Put them ina group?

You can also find your answers @ TheSwamp
Message 3 of 7
norman.yuan
in reply to: greg

Firstly, let's assume, by saying "for later use not only in the current drawing session but also for later retrieval in another completely new session and even by someone else", you mean running the same custom program/code in the same AutoCAd session or different AutoCAD session with the same program/code loaded.

 

Yes, saving data to outside data store (file, database...) and later loaded back from there is one of option. The data to be saved would be the Handles of selected entities.

 

You can also consider save them in a custom NamedDictionary. Or you can attach Xdata to the entities. If you use AutoCAD Map/Civil, you can also have options to use ObjectData/Object Classification (well, it might be a bit overkill to use them just for remembering selected entities, but hey, it is doable technically). All of these does not need external data persistence.

Message 4 of 7
greg
in reply to: greg

Thank you Jeff and Norman. 

 

I will look into the groups option and the NamedDictionary option and see what may work best in my situation.  I will get back to this project this afternoon so will post back on my results.

 

Yes, I want multiple people to be able to run the same code from different machines and access the same saved entitiy selections. 

 

Thanks,

 

Message 5 of 7
DiningPhilosopher
in reply to: greg

This is easy.  

 

Groups are essentially, 'persistent' selections that can be easily reselected at any time.

Message 6 of 7
greg
in reply to: DiningPhilosopher

From my testing, it appears that getting the handle of the selected objects and storing those would be best for my use in this particular case.  The only item I may have troubles with is selecting the actual objects when knowing the handles of the objects.  

I have found examples of converting the handle to an object id for use within other parts of my code so although I have not implemented that yet, I think it should be relatively straight forward.

 

Thank you to all of you for your assistance so far.  It is greatly appreciated.

Message 7 of 7
greg
in reply to: greg

I have been doing further research and although I still think an external file to save the handles of the selected objects is the way I will go.  I understand I could create a dictionary and store the data, but I havent a clue where to start and where to go.  So unless anyone has further ideas on this...

 

Thanks again.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost