Hi,
I try to read out all defined drawing properties of the active drawing as shown in screenshot.
All this should be done inside of my addin. The properties should be read at DocumentSave event (Event is already implemented and working, I get "Autodesk.AutoCAD.ApplicationServices.Document" as parameter from Autocad at the OnSave event function.
Can someone points me to the how to read the informations shown at General and ErpData?
Regards
Stefan
Solved! Go to Solution.
Hi,
I try to read out all defined drawing properties of the active drawing as shown in screenshot.
All this should be done inside of my addin. The properties should be read at DocumentSave event (Event is already implemented and working, I get "Autodesk.AutoCAD.ApplicationServices.Document" as parameter from Autocad at the OnSave event function.
Can someone points me to the how to read the informations shown at General and ErpData?
Regards
Stefan
Solved! Go to Solution.
Solved by sbarlage. Go to Solution.
I could solve it myself:
internal enum DrawingType
{
Unknown=0,
PID=1,
P3D=2,
Ortho=3,
Iso=4
}
Autodesk.AutoCAD.ApplicationServices.Document activeDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Autodesk.AutoCAD.Interop.AcadDocument activeAcadDocument = Autodesk.AutoCAD.ApplicationServices.DocumentExtension.GetAcadDocument(ActiveDocument) as Autodesk.AutoCAD.Interop.AcadDocument;
Autodesk.AutoCAD.DatabaseServices.Database activeDatabase = ActiveDocument.Database;
Autodesk.ProcessPower.ProjectManager.PlantProject plantProject = Autodesk.ProcessPower.PlantInstance.PlantApplication.CurrentProject;
Autodesk.ProcessPower.ProjectManager.ProjectUnitsType projectUnits = pipingProjectPart.ProjectUnitsType;
Autodesk.ProcessPower.ProjectManager.Project pnidProjectPart = plantProject.ProjectParts["PnID"];
Autodesk.ProcessPower.ProjectManager.Project pipingProjectPart = plantProject.ProjectParts["Piping"];
Autodesk.ProcessPower.ProjectManager.Project orthoProjectPart = plantProject.ProjectParts["Ortho"];
Autodesk.ProcessPower.ProjectManager.Project isometricProjectPart = plantProject.ProjectParts["Iso"];
Autodesk.ProcessPower.DataLinks.DataLinksManager pnidDataLinksManager = pnidProjectPart.DataLinksManager;
Autodesk.ProcessPower.DataLinks.DataLinksManager pipingDataLinksManager = pipingProjectPart.DataLinksManager;
Autodesk.ProcessPower.DataLinks.DataLinksManager orthoDataLinksManager = orthoProjectPart.DataLinksManager;
Autodesk.ProcessPower.DataLinks.DataLinksManager isometricDataLinksManager = isometricProjectPart.DataLinksManager;
if (pnidDataLinksManager.GetDrawingId(db) != -1)
{
drawingType = DrawingType.PID;
}
else if (pipingDataLinksManager.GetDrawingId(db) != -1)
{
drawingType = DrawingType.P3D;
}
else if (orthoDataLinksManager.GetDrawingId(db) != -1)
{
drawingType = DrawingType.Ortho;
}
else if (isometricDataLinksManager.GetDrawingId(db) != -1)
{
drawingType = DrawingType.Iso;
}
else
{
}
switch (drawingType)
{
case DrawingType.PID:
{
// Get the piping drawing category names
List<string> catNames = pnidProjectPart.GetCategoryNames(CategoryType.eDrawing);
foreach (string catName in catNames)
{
List<KeyValuePair<string, string>> props = pnidProjectPart.GetDrawingProperties(fileName, catName);
foreach (KeyValuePair<string, string> prop in props)
{
System.Diagnostics.Debug.Print($"{catName}, {prop.Key}, {prop.Value}");
}
}
}
break;
case DrawingType.P3D:
{
// Get the piping drawing category names
List<string> catNames = pipingProjectPart.GetCategoryNames(CategoryType.eDrawing);
foreach (string catName in catNames)
{
List<KeyValuePair<string, string>> props = pipingProjectPart.GetDrawingProperties(fileName, catName);
foreach (KeyValuePair<string, string> prop in props)
{
System.Diagnostics.Debug.Print($"{catName}, {prop.Key}, {prop.Value}");
}
}
}
break;
case DrawingType.Ortho:
{
// Get the piping drawing category names
List<string> catNames = orthoProjectPart.GetCategoryNames(CategoryType.eDrawing);
foreach (string catName in catNames)
{
List<KeyValuePair<string, string>> props = orthoProjectPart.GetDrawingProperties(fileName, catName);
foreach (KeyValuePair<string, string> prop in props)
{
System.Diagnostics.Debug.Print($"{catName}, {prop.Key}, {prop.Value}");
}
}
}
break;
case DrawingType.Iso:
{
// Get the piping drawing category names
List<string> catNames = isometricProjectPart.GetCategoryNames(CategoryType.eDrawing);
foreach (string catName in catNames)
{
List<KeyValuePair<string, string>> props = isometricProjectPart.GetDrawingProperties(fileName, catName);
foreach (KeyValuePair<string, string> prop in props)
{
System.Diagnostics.Debug.Print($"{catName}, {prop.Key}, {prop.Value}");
}
}
}
break;
default:
break;
}
I could solve it myself:
internal enum DrawingType
{
Unknown=0,
PID=1,
P3D=2,
Ortho=3,
Iso=4
}
Autodesk.AutoCAD.ApplicationServices.Document activeDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Autodesk.AutoCAD.Interop.AcadDocument activeAcadDocument = Autodesk.AutoCAD.ApplicationServices.DocumentExtension.GetAcadDocument(ActiveDocument) as Autodesk.AutoCAD.Interop.AcadDocument;
Autodesk.AutoCAD.DatabaseServices.Database activeDatabase = ActiveDocument.Database;
Autodesk.ProcessPower.ProjectManager.PlantProject plantProject = Autodesk.ProcessPower.PlantInstance.PlantApplication.CurrentProject;
Autodesk.ProcessPower.ProjectManager.ProjectUnitsType projectUnits = pipingProjectPart.ProjectUnitsType;
Autodesk.ProcessPower.ProjectManager.Project pnidProjectPart = plantProject.ProjectParts["PnID"];
Autodesk.ProcessPower.ProjectManager.Project pipingProjectPart = plantProject.ProjectParts["Piping"];
Autodesk.ProcessPower.ProjectManager.Project orthoProjectPart = plantProject.ProjectParts["Ortho"];
Autodesk.ProcessPower.ProjectManager.Project isometricProjectPart = plantProject.ProjectParts["Iso"];
Autodesk.ProcessPower.DataLinks.DataLinksManager pnidDataLinksManager = pnidProjectPart.DataLinksManager;
Autodesk.ProcessPower.DataLinks.DataLinksManager pipingDataLinksManager = pipingProjectPart.DataLinksManager;
Autodesk.ProcessPower.DataLinks.DataLinksManager orthoDataLinksManager = orthoProjectPart.DataLinksManager;
Autodesk.ProcessPower.DataLinks.DataLinksManager isometricDataLinksManager = isometricProjectPart.DataLinksManager;
if (pnidDataLinksManager.GetDrawingId(db) != -1)
{
drawingType = DrawingType.PID;
}
else if (pipingDataLinksManager.GetDrawingId(db) != -1)
{
drawingType = DrawingType.P3D;
}
else if (orthoDataLinksManager.GetDrawingId(db) != -1)
{
drawingType = DrawingType.Ortho;
}
else if (isometricDataLinksManager.GetDrawingId(db) != -1)
{
drawingType = DrawingType.Iso;
}
else
{
}
switch (drawingType)
{
case DrawingType.PID:
{
// Get the piping drawing category names
List<string> catNames = pnidProjectPart.GetCategoryNames(CategoryType.eDrawing);
foreach (string catName in catNames)
{
List<KeyValuePair<string, string>> props = pnidProjectPart.GetDrawingProperties(fileName, catName);
foreach (KeyValuePair<string, string> prop in props)
{
System.Diagnostics.Debug.Print($"{catName}, {prop.Key}, {prop.Value}");
}
}
}
break;
case DrawingType.P3D:
{
// Get the piping drawing category names
List<string> catNames = pipingProjectPart.GetCategoryNames(CategoryType.eDrawing);
foreach (string catName in catNames)
{
List<KeyValuePair<string, string>> props = pipingProjectPart.GetDrawingProperties(fileName, catName);
foreach (KeyValuePair<string, string> prop in props)
{
System.Diagnostics.Debug.Print($"{catName}, {prop.Key}, {prop.Value}");
}
}
}
break;
case DrawingType.Ortho:
{
// Get the piping drawing category names
List<string> catNames = orthoProjectPart.GetCategoryNames(CategoryType.eDrawing);
foreach (string catName in catNames)
{
List<KeyValuePair<string, string>> props = orthoProjectPart.GetDrawingProperties(fileName, catName);
foreach (KeyValuePair<string, string> prop in props)
{
System.Diagnostics.Debug.Print($"{catName}, {prop.Key}, {prop.Value}");
}
}
}
break;
case DrawingType.Iso:
{
// Get the piping drawing category names
List<string> catNames = isometricProjectPart.GetCategoryNames(CategoryType.eDrawing);
foreach (string catName in catNames)
{
List<KeyValuePair<string, string>> props = isometricProjectPart.GetDrawingProperties(fileName, catName);
foreach (KeyValuePair<string, string> prop in props)
{
System.Diagnostics.Debug.Print($"{catName}, {prop.Key}, {prop.Value}");
}
}
}
break;
default:
break;
}
You're welcome to mark your own post as a solution ^^
You're welcome to mark your own post as a solution ^^
Can't find what you're looking for? Ask the community or share your knowledge.