.NET

.NET

Reply
Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 1 of 7 (228 Views)

Save selected objects for later use

228 Views, 6 Replies
02-13-2013 06:44 PM

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.

Valued Mentor
jeff
Posts: 338
Registered: ‎05-12-2009
Message 2 of 7 (225 Views)

Re: Save selected objects for later use

02-13-2013 06:58 PM in reply to: greg

Put them ina group?

You can also find your answers @ TheSwamp
*Expert Elite*
norman.yuan
Posts: 1,064
Registered: ‎04-27-2009
Message 3 of 7 (201 Views)

Re: Save selected objects for later use

02-14-2013 06:43 AM 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.

Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 4 of 7 (193 Views)

Re: Save selected objects for later use

02-14-2013 06:51 AM 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,

 

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 5 of 7 (177 Views)

Re: Save selected objects for later use

02-14-2013 04:39 PM in reply to: greg

This is easy.  

 

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

Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 6 of 7 (163 Views)

Re: Save selected objects for later use

02-15-2013 05:32 AM 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.

Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 7 of 7 (145 Views)

Re: Save selected objects for later use

02-15-2013 01:19 PM 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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.