Could you please post a link to this training material? I would like it too. Specifically, I'm trying to figure out how to marshal an external Autocad.Application into a PlantProject:
PlantApplication pApp = (PlantApplication)Marshal.GetActiveObject("AutoCAD
But it does not work because it is not an Interface object. For more, please view my other post:
Thanks in advance.
PlantApplication is a singleton object in the PnPProjectManagerMgd.dll assembly. You just use it without acquiring it as a COM object. AcadApplication and PlantApplication are unrelated.
Yes, I realize PlantApplication is not a COM object and is unrelated to AcadApplication, but I want to expose the SmartPlant P&ID objects through COM externally. Is there any way to do that? I need to Marshal SmartPlant from the Autocad.Application somehow to get an external executable to interface with the tables.
"I want to expose the SmartPlant P&ID objects through COM externally"
If you mean to expose the Plant P&ID objects through COM, then you will have to create COM objects that wrap the .NET objects and act as proxies. What are SmartPlant P&ID Objects?
I'm referring to all objects in the Autodesk.ProcessPower tree.
Also, I do not want to wrap the .NET objects and import them into AutoCAD. The issue with using the method you describe, is while I am building my .NET application, I compile and produce tlb and dll file. I then tell AutoCAD to either NETLOAD or VBA import Reference to gain access to my .NET objects. The problem is that in order to make changes, I have to completely close out AutoCAD, recompile, then open it back up and wait... I have to wait 30 seconds for AutoCAD to boot up again, which as a developer, makes it difficult to make code changes line by line.
The other issue is I want it to be a completely anonymous process that runs in the background, and triggers at 9 pm every night, opening AutoCAD if it closed to in order to run excel backup commands, followed by Access import commands.
Unfortunately, we only support native (i.e. ARX/DBX) and .NET application development with the Plant SDK. We have COM object stubs for properties palette integration but the properties themselves use dynamic properties APIs. See PnIDCOM.tlb and PnP3dCOM.tlb.
You may be able to do what you need with just the AutoCAD COM APIs. How do you need to interact with the P&ID objects?
I just tried using PnIDCOM.tlb. I could not find any PnP3dCOM files though. The only Interface object I could think of being useful, I tried:
object marshalApp = Marshal.GetActiveObject("AutoCAD.Application");
AcPnIdAsset asset = (PnIDCOMLib.AcPnIdAsset)marshalApp;
But it did not work. I am trying to grab ahold of an Autodesk.ProcessPower object and manipulate it through an Interface object, but I can find nothing. I'm assuming there is just no way to do it?
My goal in exporting and importing is to specifically manipulate Line List, Instrument List, Equipment List, Valve List, Control Valve List, Specialty Items List, and Document Registry. I want to run these queries, go through record by record in the database, and make changes to all custom fields by PnPID according to what was done by the engineer in our MS Access database.
Marshal.GetActiveObject("AutoCAD.Application") will return an AcadApplication object for the current running instance of ACAD.EXE. You cannot cast it to anything in the Autodesk.ProcessPower tree.
We support C++ native APIs and .NET APIs. As a developer, you can expose it to other environments such as COM by developing the bridge. My suggestions is to write a .NET plug-in with the APIs you need that uses our .NET APIs and then expose your APIs to COM.
Hope this help.
Ah, bummer. I'm not quite sure how I can build the bridge, but that is ok. I'll just resort to reloading AutoCAD each time, there are bigger fish to fry.
As for training manuals and documentation, I desperately need them. There has to be an explanation or documentation for all the classes in the PnP dll's.
Specifically, I'm most interested in querying ProcessPower.dcf: I want to query the Line List, Instrument List, Valve List, and so on. The farthest I've gotten is DataLinksManager to get the ProcessPower.dcf. Beyond that I don't know what to do since I could find no documentation anywhere:
ProjectPartCollection projParts = PlantApplication.CurrentProject.ProjectParts; Project oPrj = projParts["PnId"]; DataLinksManager dlm = oPrj.DataLinksManager; PnPDatabase db = dlm.GetPnPDatabase(); List<string> strList = oPrj.GetCategoryNames(CategoryType.ePickList); PnPDataManager dm = ??? //Where is this configured??? string modeid = "???"; //What goes here??? string filePath = "C:\\Jesse\\Assignments\\Smart P&ID\\FGD PID - JESSE\\???.xls"; //Path of new excel file or existing one? ExcelManager xlMan = new ExcelManager(oPrj, modeid, filePath); bool bFilter = false; List<ExportDataSet> viewList; foreach(???) viewList.Add(new ExportDataSet(???)); //No constructor defined! xlMan.ExportDataSets(viewList, bFilter, dm);
Okay I am getting closer (in regards to nailing down the lists). Here is the additional code I used to get the lists I'm interested in:
PnPTables tbls = db.Tables; PnPTable vltbl = tbls["HandValves"]; //Valve List PnPTable sltbl = tbls["PipingSpecialtyItems"];//Specialty Item List PnPTable lltbl = tbls["PipeLines"]; //Line List PnPTable eltbl = tbls["Equipment"]; //Equipment List PnPTable iltbl = tbls["Instrumentation"]; //Instrument List PnPTable dltbl = tbls["PnPDrawings"]; //Drawing/P&ID List PnPTable cltbl = tbls["ControlValve"]; //Control Valve List PnPTable cltbl = tbls["TieInSymbol"]; //Tie-In List
I would still like documentation if that is available, it takes awhile to hunt all this stuff down in the XML files and using foreach loops to list all names in a data collection. I also still don't know how to use the ExcelManager and compile a
List<ExportDataSet> viewList since ExportDataSet doesn't have a constructor (according to Visual Studio).
Access a broad range of knowledge to help get the most out of your products and services.
Start with some of our most frequented solutions to get help installing your software.
The AutoCAD P&ID forum has moved into it's very own category page, and can no longer be found within the Additional Product Forums.
Upgrading to a 2015 product? Make sure to check these out 1st!