.NET

Reply
Active Contributor
PATRICKCAREY9382
Posts: 27
Registered: ‎09-25-2008
Message 1 of 3 (297 Views)
Accepted Solution

Accessing database tables with AutoCAD PNID 2011

297 Views, 2 Replies
09-21-2011 11:35 AM

Hello,

I'm having a problem accessing data manager tables in the 2011 version.  My C# .NET code worked fine with 2010.  Here is a sample of the 2010 code that works, but returns zero length tables in 2011.

 

C#

ProjectPartCollection oPP = PlantApplication.CurrentProject.ProjectParts;

PlantProject oPProj = PlantApplication.CurrentProject;
Project oProj = oPP["PnId"];

 

try
            {
                //get ACAD data table
                System.Collections.Specialized.StringCollection strColl =                      Autodesk.ProcessPower.DataLinks.DataLinksManager.GetLinkManagerNames();
                if (strColl.Count > 0)
                {
                    String dlName = strColl[0];
                    if (dlName != String.Empty)
                    {
                      
                        dlObj = oProj.DataLinksManager;
                        PnPDatabase pnpDB = dlObj.GetPnPDatabase();
                       
                        // get a reference to all the tables in the P&ID project
                        // database
                        PnPTable drawings= null;
                       
                        drawings = pnpDB.Tables["PnPDrawings"];
                        drawings.Select();
                        PnPRows drawingRows = drawings.Rows;
                        PnPRowIdArray DwgRowIndexes = drawings.SelectCachedIds();

  ......................................

........................................

end of try loop;

 

The last two lines fail to object any meaningful data in 2011.  In 2010, I would have all the table rows and could access tags and asset information. 

 

Any help would be appreciated.

Thanks,

Patrick

I do this and it works in 2010+

 

PnPTable drawings= pnpDB.Tables["PnPDrawings"];
PnPRow[] rows = drawings.Select();

 

I have had fairly unpredictable results using PnPTable.Rows, perhaps because of caching, but Im not sure at this point. The code above always seems to work.

 

Hope that helps

 

jess

Active Contributor
jessaskey
Posts: 38
Registered: ‎10-04-2009
Message 2 of 3 (261 Views)

Re: Accessing database tables with AutoCAD PNID 2011

10-06-2011 05:30 PM in reply to: PATRICKCAREY9382

I do this and it works in 2010+

 

PnPTable drawings= pnpDB.Tables["PnPDrawings"];
PnPRow[] rows = drawings.Select();

 

I have had fairly unpredictable results using PnPTable.Rows, perhaps because of caching, but Im not sure at this point. The code above always seems to work.

 

Hope that helps

 

jess

Active Contributor
PATRICKCAREY9382
Posts: 27
Registered: ‎09-25-2008
Message 3 of 3 (241 Views)

Re: Accessing database tables with AutoCAD PNID 2011

10-07-2011 01:06 PM in reply to: jessaskey

Thanks.

I believe your solution is the only way to do it now.  I've run into some other issues such that accessing some of the table parameters is not as easy as it was before and it probably is related to caching. 

 

I've coded up this solution and it works for me for now.  I have other scripts that may still be broken, but I'll deal with them later.

--Patrick

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!