Issue
I managed to find all the butt welds in the drawing, they are kept inside the Autodesk.ProcessPower.PnP3dObjects.Connector class. But I can’t find the “Status” property in these objects. How can I access this property and change its value?
Solution
The “Status” property and many others are stored in a SubPart of the Connector object. So, what we need to do is to iterate through these SubParts and find one of the WeldSubPart type. Here is a sample (some error checking is omitted for brevity):
[CommandMethod("UpSt", CommandFlags.UsePickSet)]
public void UpdateStatus_ShortVersion()
{
try
{
// Make sure you pre-selected a Connector of Weld type!
PromptSelectionResult selResult = acApp.DocumentManager.
MdiActiveDocument.Editor.SelectImplied();
SelectionSet selSet = selResult.Value;
ObjectId[] objIds = selSet.GetObjectIds();
ObjectId weldObjID = objIds[0];
Database db =acApp.DocumentManager.MdiActiveDocument.Database;
using (Transaction tr =
db.TransactionManager.StartTransaction())
{
PnP3D.Connector wld = tr.GetObject( weldObjID,
OpenMode.ForRead, false, true) as PnP3D.Connector;
DataLinksManager dlm = PlantApplication.CurrentProject.
ProjectParts["Piping"].DataLinksManager;
PartsRepository projectParts = DataLinksManager3d.
Get3dManager(dlm).ProjectPartsRepository;
PnP3D.SubPartCollection subPartColl = wld.AllSubParts;
int index = 1; // NOTE: We start from 1, not from 0!
foreach (PnP3D.SubPart sp in subPartColl)
{
if (sp is PnP3D.WeldSubPart)
{
int rowId = dlm.FindAcPpRowId( dlm.MakeAcPpObjectId(
weldObjID, index ));
Autodesk.ProcessPower.PartsRepository.Part partWld =
projectParts.FindPart(rowId);
// To set properties we need to call BeginEdit()
// and EndEdit()
partWld.BeginEdit();
partWld["Status"] = "Existing";
partWld.EndEdit();
}
index++;
} // foreach subpart
dlm.AcceptChanges();
tr.Commit();
} // using
}
catch (System.Exception e)
{
acApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage(
e.ToString());
}
} // UpdateStatus_ShortVersion()