Hi,
Want to know if someone has decoded PropertyTypeCode property of DynamicBlockReferenceProperty? It seems 5 is used for visibility states, 1 for position and angular parameters, 12 for origin, but that's it almost all i have so far.
Gaston Nunez
Hi,
Any specific reason for needing those value in your code ?
If you can provide me the usage, I can find out from my colleagues to see if they have any information on this.
Thank you.
Hi,
Thanks for answer, I was not aware that I had to have a reason to ask. Any way, my question was answered by Alexander Rivilis in The swamp, and the answer was to look at acdbabb.h in the Inc folder of the SDK, that file send me to acdb.h, and that file has:
enum DwgDataType { kDwgNull = 0,
kDwgReal = 1,
kDwgInt32 = 2,
kDwgInt16 = 3,
kDwgInt8 = 4,
kDwgText = 5,
kDwgBChunk = 6,
kDwgHandle = 7,
kDwgHardOwnershipId = 8,
kDwgSoftOwnershipId = 9,
kDwgHardPointerId = 10,
kDwgSoftPointerId = 11,
kDwg3Real = 12,
kDwgInt64 = 13,
kDwgNotRecognized = 19 };
As for the reason, I was trying to find what type a dynamic property is when we are iterating it, using PropertyTypeCode (a visibility state, distance, etc).
Thanks again,
Gaston Nunez
Hi,
Glad to know you got that info from Alexander.
You dont require a reason to ask 🙂 I asked for it to satisfy my curiosity and to pass it on to my colleagues if I need to ask them.
I made a quick test with a sample drawing (see attachment) that has a dynamic block with all parameters. The result is shown as below:
PropertyName | PropertyTypeCode |
Position X | 40 |
Position Y | 40 |
Distance | 40 |
Origin | 11 |
Distance1 | 40 |
Angle | 40 |
Origin | 11 |
X Distance | 40 |
Y Distance | 40 |
Origin | 11 |
Angle1 | 40 |
Origin | 11 |
Flip state | 70 |
Visibility | 1 |
Lookup | 1 |
From that table, PropertyTypeCode is useless to identify a parameter type, as it is not unique. So we have to use PropertyName to specify a parameter type. It is better the API to have a new enum (let's call PropertyType), so "Position X" will associate with an enum PropertyType.PositionX, and so on. Using PropertyName to find the type of a parameter is not strongly-typed and hard-coded.
Please see the sample code to write all dynamic block parameters to the AutoCAD editor:
[CommandMethod("GetAllDynamicBlockParameters")] public void GetAllDynamicBlockParameters() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor editor = doc.Editor; var option = new PromptEntityOptions("\n" + "Select a block"); PromptEntityResult result = editor.GetEntity(option); if (result.Status == PromptStatus.OK) { ObjectId id = result.ObjectId; using (Transaction trans = db.TransactionManager.StartTransaction()) { var blockRef = (BlockReference)trans.GetObject(id, OpenMode.ForRead); DynamicBlockReferencePropertyCollection properties = blockRef.DynamicBlockReferencePropertyCollection; for (int i = 0; i < properties.Count; i++) { DynamicBlockReferenceProperty property = properties[i]; editor.WriteMessage("\n" + property.PropertyName + " | " + property.PropertyTypeCode + " | " + property.Value); } } } }
-Khoa
Im testing some blocks in 2023, and the Visibility State seems to be enum 5. Did these change at some point?
Here are the results I'm getting using AutoCAD 2023 with the file and code from above:
PropertyName | PropertyTypeCode |
Position X | 1 |
Position Y | 1 |
Distance | 1 |
Origin | 12 |
Distance1 | 1 |
Angle | 1 |
Origin | 12 |
X Distance | 1 |
Y Distance | 1 |
Origin | 12 |
Angle1 | 1 |
Origin | 12 |
Flip state | 3 |
Visibility | 5 |
Lookup | 5 |
Can't find what you're looking for? Ask the community or share your knowledge.