![]() ![]() Here’s the C# code that allows you to manage “locking objects” in an AutoCAD drawing. In this post we’re going to create an API to simplify this – via extension methods on the ObjectId and Transaction classes – and in tomorrow’s we’ll implement some commands to exercise it. I’d considered storing a list in memory – and then exposing an extension method to check whether an id was on the list – but had then realised that making this persistent, and using Database.Purge() to perform the check, would keep this much simpler and more unified with AutoCAD. The idea related to providing a way to identify “core” (which could mean system) objects, so that your application doesn’t inadvertently delete them. ![]() I probably wouldn’t have gone back and looked at this, but the topic reared its head again in relation to this recent post (and its comments). It’s the second suggestion that we’re going to explore over the next couple of posts… The question and my first suggestion, above, relates to the code shown in the blog post this comment related to. This has the advantage of also stopping the standard PURGE command from removing those objects. Or you can create an object that's owned at some level by the Database (an Xrecord placed inside the Named Objects Dictionary should do it) that contains "hard" references to the objects you wish to keep (which means using DxfCode.HardPointerId - or one of the indeces just following it - when creating your TypedValues). You can maintain your own list of objects "to keep" and remove any items that are on this list from idsToPurge before you erase them. For example, if a particular text style was included in the drawing that I did not want to be purged. I was wondering if there's an easy way to modify the objects to purge. Here’s a question I received via a blog comment back in 2009: This is one of those topics that has been at the back of my mind for a number of years.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |