AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Retrieving Value in PropertyDefinitionLocation

1 REPLY 1
Reply
Message 1 of 2
PengYen6809
490 Views, 1 Reply

Retrieving Value in PropertyDefinitionLocation


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());
            }
        }
    }
}

 


1 REPLY 1
Message 2 of 2
jeff
in reply to: PengYen6809

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());

                                    }
                                }
                            }
                        }
                    }

 

You can also find your answers @ TheSwamp

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost