Search code examples
c#autocad-plugin

Get Autocad Project Details


I'm trying to get project details information of an Autocad project by means of C# in my plug-in. I can access a few properties in the following class.

Autodesk.ProcessPower.PlantInstance.PlantApplication.CurrentProject

However this class does not provide all project details such as project number etc. How can I access to project details via C#?


Solution

  • Took be a bit to figure out to get project number from project details, so thought I would post my solution here:

    PnIdProject oPnIdProject =
        (PnIdProject)PlantApplication.CurrentProject.ProjectParts["PnID"];
    
    //Assuming you want Project Number from the "General" category.  If you have
    //a custom category property you want, just replace "General" with the name
    //of the custom category
    List<ProjectProperty> metaData = 
        oPnIdProject.GetProjectPropertyMetadata("General");
    
    string projectNumberString = "";
    
    foreach (ProjectProperty prop in metaData)
    {
        if (prop.Name == "Project_Number")
        {
            projectNumberString = oPnIdProject.GetProjectPropertyValue(prop);
        }
    }
    

    I'm assuming the same could be done for any project part...