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