Hi.
I am working on extracting information from DWG with extended Property Set Definitions.
I have added Location Property on my Door objects, and would like to retrieve it in my application.
Definition as shown in AutoCAD > Manage > Style Manager > Property Set Definitions
DoorObjects Property Set
Name: AtSpaceID
Description: Space - SpaceObjects - SpaceID
Type: Location (becomes Automatic inside .NET API code)
Source: Space - SpaceObjects - SpaceID
Space Objects Property Set
Name: SpaceID
Description: SpaceID
Type: Integer
I have tried the .NET API. see Code below. I am stuck at PropertyDefinitionLocation. Not too sure where I can retrieve the value for my AtSpaceID at my DoorObjects.
Any one has experience in doing so? Please advice. Thanks.
I tried the following code below and it throws error such as eInvalidInput or eNotApplicable.
Part of my code
Door doorEntity = trans.GetObject(doorObjID, OpenMode.ForRead) as Door; ObjectIdCollection idsPropSet = PropertyDataServices.GetPropertySets(doorEntity); foreach (ObjectId idPropSet in idsPropSet) { PropertySet propSet = trans.GetObject(idPropSet, OpenMode.ForRead) as PropertySet; PropertySetDefinition propSetDef = trans.GetObject(propSet.PropertySetDefinition, OpenMode.ForRead) as PropertySetDefinition; PropertyDefinitionCollcetion propDefs = propSetDef.Definitions; foreach (PropertyDefinition propDef in propDefs) { if(propDef.Automatic) //the Space { ObjectIdCollection idsDummy = new ObjectIdCollection(); if(propDef.GetType().ToString().Equals("Autodesk.Aec.PropertyData.DatabaseServices.PropertyDefinitionLocation")) { PropertyDefinitionLocation propDefLoc = propDef as PropertyDefinitionLocation; //this give me eInvalidInput error MessageBox.Show(propSetDef.GetValue(propDefLoc.Id, doorObjId, idsDummy).ToString()); //give me Automatic Property -- not applicable in this context MessageBox.Show(propDefLoc.FormatId, idsDummy).ToString()); } } } }
Small change
Door doorEntity = tr.GetObject(id, OpenMode.ForRead) as Door; ObjectIdCollection idsPropSet = PropertyDataServices.GetPropertySets(doorEntity); foreach (ObjectId idPropSet in idsPropSet) { PropertySet propSet = tr.GetObject(idPropSet, OpenMode.ForRead) as PropertySet; PropertySetDefinition propSetDef = tr.GetObject(propSet.PropertySetDefinition, OpenMode.ForRead) as PropertySetDefinition; PropertyDefinitionCollection propDefs = propSetDef.Definitions; foreach (PropertyDefinition propDef in propDefs) { if (propDef is PropertyDefinitionLocation) //the Space { ObjectIdCollection idsDummy = new ObjectIdCollection(); { //this does NOT give me eInvalidInput error MessageBox.Show(propSetDef.GetValue(propDef.Id, id, idsDummy).ToString()); } } } } }