Getting all the Properties of a selected Pipe in Plant3d using C#.NET

by Fenton Webb

I was just looking around to see if there was some sample code out on the web which showed how to obtain the properties of a given pipe in Plant3d and found nothing, so I thought I’d put one together for you all to enjoy!!

Just get hold of the DataLinksManager and utilize the GetAllProperties(). Here’s what I am talking about…

// get all the properties of a selected object in Plant3d

// by Fenton Webb, Autodesk, 29/05/2012

[CommandMethod("GetPipingProperties")]

public void GetPipingProperties()

{

  // get the AutoCAD Editor object so we can print to the command line

  Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

 

  // select the object

  PromptEntityResult res = ed.GetEntity("Pick Object obtain properties : ");

  // if something selected

  if (res.Status == PromptStatus.OK)

  {

    // get the current project object

    PlantProject currentProj = PlantApplication.CurrentProject;

    // get the Piping project part

    PipingProject pipingProj = (PipingProject)currentProj.ProjectParts["Piping"];

 

    // get the data links manager

    DataLinksManager dlm = pipingProj.DataLinksManager;

    // and then get the row id for the selected object

   
int
rowId = dlm.FindAcPpRowId(res.ObjectId);

 

    List<KeyValuePair<string, string>> properties;

    properties = dlm.GetAllProperties(rowId, true);

    // Iterate through the entries in the list.

    for (int i = 0; i < properties.Count; i++)

      ed.WriteMessage("\nProperty name:" + properties[i].Key +

                            " = " + properties[i].Value);

  }

}

 


Comments

10 responses to “Getting all the Properties of a selected Pipe in Plant3d using C#.NET”

  1. Is there any way to tell the datatype of the property that is retrieved?

  2. You can use properties[i].Value.GetType() to work out the datatype.

  3. Hi, Fenton, do you know how to use the method SetProperties() to set the PipelineGroup’s Tag?

  4. Hi,
    why the properties = dlm.GetAllProperties(rowId, true);
    can’t get weld number of WELD?

  5. can’t get weld number of WELD
    Can’t get “ValveCode” of a Valve as well :(
    So, the method’s name is wrong.
    The Plant SDK Developer Reference (plantsdk_ref.chm) says:

    This is GetAllProperties, a member of class DataLinksManager.
  6. anonymous Avatar
    anonymous

    how to Convert 2D pipe To #D using API

  7. How to get only specific properties? For example i want to get only General properties from Properties tab for a model..

  8. rohitraghavraghav1@gmail.com Avatar
    rohitraghavraghav1@gmail.com

    i have doubt how can i get only object visual view check is true property only

  9. rohitraghavraghav1@gmail.com Avatar
    rohitraghavraghav1@gmail.com

    please help me is it possible to get only showing property form property in plant 3D
    dlm.GettAllProp() from this function I got all property but i want only object visual view (True) checked property . any one can help me

  10. Muhammad Shoaib Anjum Avatar
    Muhammad Shoaib Anjum

    Good code. Is there a way to change the value of any of these property?

Leave a Reply to Fenton WebbCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading