I'm trying to get and edit the properties values of an natively created equipment in Plant3d . This equipments, by default, comes without the majority of the properties and the others are filled with generic values (like Long Description (Size) as "Heat Exchanger", for example).
I tried to use this code to get this:
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.ProcessPower.ProjectManager;
using Autodesk.ProcessPower.PlantInstance;
using Autodesk.ProcessPower.DataLinks;
using System.Windows.Forms;
using Autodesk.ProcessPower.PnP3dObjects;
namespace ParametEquip
{
public class Plugin
{
[CommandMethod("PARAMEQ", CommandFlags.UsePickSet)]
public static void ParametEquip()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
PlantProject projeto = PlantApplication.CurrentProject;
Project pj = projeto.ProjectParts["PnId"];
DataLinksManager dlm = pj.DataLinksManager;
BlockTable bt = (BlockTable)trans.GetObject(doc.Database.BlockTableId, OpenMode.ForWrite);
if (bt != null)
{
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
if (btr != null)
{
foreach (ObjectId id in btr)
{
Entity ent = (Entity)trans.GetObject(id, OpenMode.ForWrite);
int linha = dlm.FindAcPpRowId(ent.ObjectId);
List<KeyValuePair<string, string>> props;
props = dlm.GetAllProperties(linha, true);
foreach (var prop in props)
{
MessageBox.Show($"Propriedade: {prop.Key} \nValor: {prop.Value}");
}
}
}
}
trans.Commit();
}
}
}
}
But I get this error: enter image description here Details:
Application does not support just-in-time (JIT) debugging. See the end of this message for details.
Exception Text ************** Autodesk.ProcessPower.DataLinks.DLException: ObjectDoesNotHaveLink at Autodesk.ProcessPower.DataLinks.DLException.ThrowError(_EPpDataLinksStatus stat) at Autodesk.ProcessPower.DataLinks.DataLinksManager.FindAcPpRowId(ObjectId oid) at ParametEquip.Plugin.ParametEquip() in A:\11-Temporário\João Castro\Parametrização de Equipamentos\ParamEquip\ParamEquip.cs:line 37
If anyone has an idea about this error or about other ways to achieve this properties, anything will help me a lot. Thanks!
You seem to be trying to find the object in the P&ID database,
Project pj = projeto.ProjectParts["PnId"];
Which is causing the exception ObjectDoesNotHaveLink
, which means "I cant find what you are looking for".
To access the 3D data, you must use:
Project pj = projeto.ProjectParts["Piping"];