.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accessing database tables with AutoCAD PNID 2011

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
PATRICKCAREY9382
574 Views, 2 Replies

Accessing database tables with AutoCAD PNID 2011

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

2 REPLIES 2
Message 2 of 3

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

Message 3 of 3

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost