简体   繁体   中英

Storing data in a drawing AutoCad C#

In one dwg file I will have several drawings. Each as a separate whole. I want to make an overlay to describe the bars and draw them from the drawing. The numbering is done automatically. The most important thing is that every drawing starts from scratch, from position 1 (everything within the same file).

How to store all bar data?

The values ​​must be kept constant. When you open the file again, you must have access to continue the drawing.

I know there is XData but I do not know how to apply it in this situation. Assigning variables to an object somehow does not seem to me here. Are there no more storage options in the latest versions such as in a dictionary or a list?

Can you create an external database and store all the information you need? If so, in what way?

Stored data are not just single values ​​for whole collections. One bar will contain different information such as number, length, diameter and bars in the drawing can be very much.

Additional question: A bar consists of a description, a dimension, and a line or polyline. Would it be better to place this set in a new class with MText MLeader and Polyline objects or as a block with elements and attributes?

Everything that can be found here in the forums or blogs is a few years old and I hope that we already have some interesting methods for the given problem. Thank you in advance for your help.

Where you store the data depends on who needs to have access to it. Users don't have direct access to Xdata or ExtensionDictionary . You could use blocks with attributes to store the data since you know what the properties are. Attributes are user-accessible and are basically a key-value store for each block. MLeaders is another way but it isn't much of a data model. It really depends on who uses the data and how.

Everything that can be found here in the forums or blogs is a few years old

That doesn't matter, AutoCAD hasn't changed a whole lot over the years, the only obsolete information is where new features have changed things or the pre-2013 API where things were in different places, there isn't much that's different from 10 years ago.

See the AutoCAD Tag wiki for more dev resources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM