AutoCAD P&ID General

Reply
Contributor
jbrumbau
Posts: 16
Registered: ‎07-05-2012
Message 11 of 24 (349 Views)

Re: Reference to Project Database, DLM, PnPDatabase

07-05-2012 08:21 AM in reply to: jessaskey

Hello Jorge,

 

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.Application");

But it does not work because it is not an Interface object. For more, please view my other post:

http://forums.autodesk.com/t5/AutoCAD-P-ID/How-to-grab-instance-of-PlantApplication-or-PlantProject-...

 

Thanks in advance.

Employee
lopezjo
Posts: 102
Registered: ‎07-26-2007
Message 12 of 24 (346 Views)

Re: Reference to Project Database, DLM, PnPDatabase

07-05-2012 01:37 PM in reply to: jbrumbau

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.



Jorge Lopez
Software Architect
Autodesk Plant Solutions
Autodesk, Inc.

Contributor
jbrumbau
Posts: 16
Registered: ‎07-05-2012
Message 13 of 24 (344 Views)

Re: Reference to Project Database, DLM, PnPDatabase

07-05-2012 01:40 PM in reply to: lopezjo

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.

Employee
lopezjo
Posts: 102
Registered: ‎07-26-2007
Message 14 of 24 (340 Views)

Re: Reference to Project Database, DLM, PnPDatabase

07-05-2012 02:08 PM in reply to: jbrumbau

"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?



Jorge Lopez
Software Architect
Autodesk Plant Solutions
Autodesk, Inc.

Contributor
jbrumbau
Posts: 16
Registered: ‎07-05-2012
Message 15 of 24 (338 Views)

Re: Reference to Project Database, DLM, PnPDatabase

07-05-2012 02:15 PM in reply to: lopezjo

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.

Employee
lopezjo
Posts: 102
Registered: ‎07-26-2007
Message 16 of 24 (333 Views)

Re: Reference to Project Database, DLM, PnPDatabase

07-05-2012 02:23 PM in reply to: jbrumbau

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?



Jorge Lopez
Software Architect
Autodesk Plant Solutions
Autodesk, Inc.

Contributor
jbrumbau
Posts: 16
Registered: ‎07-05-2012
Message 17 of 24 (331 Views)

Re: Reference to Project Database, DLM, PnPDatabase

07-05-2012 02:43 PM in reply to: lopezjo

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.

 

Employee
lopezjo
Posts: 102
Registered: ‎07-26-2007
Message 18 of 24 (325 Views)

Re: Reference to Project Database, DLM, PnPDatabase

07-06-2012 07:46 AM in reply to: jbrumbau

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.

 



Jorge Lopez
Software Architect
Autodesk Plant Solutions
Autodesk, Inc.

Contributor
jbrumbau
Posts: 16
Registered: ‎07-05-2012
Message 19 of 24 (323 Views)

Re: Reference to Project Database, DLM, PnPDatabase

07-06-2012 08:11 AM in reply to: lopezjo

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);

 Please help.

Contributor
jbrumbau
Posts: 16
Registered: ‎07-05-2012
Message 20 of 24 (320 Views)

Re: Reference to Project Database, DLM, PnPDatabase

07-06-2012 10:08 AM in reply to: jbrumbau

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).

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

New AutoCAD P&ID Category!

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.

Ask the Community