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

Retrieve common properties from the selected objects in the sweep. (Plan API)

0 REPLIES 0
Reply
Message 1 of 1
traiduong014969
167 Views, 0 Replies

Retrieve common properties from the selected objects in the sweep. (Plan API)

Hi all,

This is my code. I've edited it to retrieve properties from a single object that I select. Suppose I've selected multiple objects from the Line Number Tag category. All of them have common properties such as status, material, line name, etc. However, I don't know how to retrieve common properties when sweeping objects in the Line Number Tag category.

So, can someone help me edit this code so that I can retrieve common properties of selected objects, not just a single object?

 

 

[CommandMethod("GetP")]
public void GetPipingProperties()
{
    Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
    PromptEntityResult res = ed.GetEntity("Pick Object obtain properties : ");
    if (res.Status == PromptStatus.OK)
    {
        PlantProject currentProj = PlantApplication.CurrentProject;
        PipingProject pipingProj = (PipingProject)currentProj.ProjectParts["Piping"];
        DataLinksManager dlm = pipingProj.DataLinksManager;
        int rowId = dlm.FindAcPpRowId(res.ObjectId);

        
        List<KeyValuePair<string, string>> allProperties = dlm.GetAllProperties(rowId, true);
        PipingProperties selectedProperties = new PipingProperties();
        foreach (var property in allProperties)
        {
            
            if (property.Key.Equals("Status", StringComparison.OrdinalIgnoreCase))
            {
                selectedProperties.Size = property.Value;
            }
            
            else if (property.Key.Equals("Material", StringComparison.OrdinalIgnoreCase))
            {
                selectedProperties.Spec = property.Value;
            }
            else if (property.Key.Equals("LineNumberTag", StringComparison.OrdinalIgnoreCase))
            {
                selectedProperties.LineNumberTag = property.Value;
            }
            
        }
         ed.WriteMessage("\nStatus: " + selectedProperties.Size);
         ed.WriteMessage("\nMaterial: " + selectedProperties.Spec);
         ed.WriteMessage("\nLineNumberTag: " + selectedProperties.LineNumberTag);
    }
}

 

 

 

Tags (2)
0 REPLIES 0

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

Post to forums  

Autodesk Design & Make Report