using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.ProcessPower.ProjectManager; // PnPProjectManagerMgd.dll
using Application = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.ProcessPower.P3dProjectParts; // PnP3dProjectPartsMgd.dll
using Autodesk.ProcessPower.DataLinks; // PnPDataLinks.dll
using Autodesk.ProcessPower.PlantInstance;
using Autodesk.ProcessPower.DataObjects; // PnPDataObjects.dll
[CommandMethod("my_test")]
public static void My_test()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PlantProject currentProj = PlantApplication.CurrentProject;
PipingProject pipeProj = (PipingProject)currentProj.ProjectParts["Piping"];
DataLinksManager dlm = pipeProj.DataLinksManager;
PnPDatabase db = dlm.GetPnPDatabase();
int dwgRowId = dlm.GetDrawingId(Application.DocumentManager.MdiActiveDocument.Database);
// получаем линии трубопроводов в текущем чертеже Plant 3D
PnPRowIdArray groupPlantIds = dlm.GetRelatedRowIds("P3dDrawingLineGroupRelationship", "Drawing", dwgRowId, "LineGroup");
PnIdProject pidProj = (PnIdProject)currentProj.ProjectParts["PnId"];
DataLinksManager dlmPid = pidProj.DataLinksManager;
PnPDatabase pidDb = dlmPid.GetPnPDatabase();
string tag = "";
foreach (int groupId in groupPlantIds)
{
PnPRow rowLineGroup = db.GetRow(groupId);
try
{
tag = rowLineGroup["Tag"] as string; // номер линии (Tag), одинаков для чертежей Plant и P&ID
}
catch
{
Application.ShowAlertDialog("Ошибка получения данных по Номеру линии (tag)");
}
PnPRow[] linegroup = pidDb.Tables["PipeLineGroup"].Select("Tag='" + tag + "'");
if (linegroup.Length != 0)
{
// LineGroupFrom - указываем из какого поля нужно получить данные
string LineGroupFrom = linegroup[0]["LineGroupFrom"] as string;
ed.WriteMessage("\n Tag: " + tag + "; LineGroupFrom " + LineGroupFrom + "\n");
}
// ... далее обрабатываем полученные данные
}
}