• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Active Contributor
    Posts: 27
    Registered: ‎09-25-2008
    Accepted Solution

    Accessing database tables with AutoCAD PNID 2011

    219 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

    Please use plain text.
    Active Contributor
    Posts: 35
    Registered: ‎10-04-2009

    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

    Please use plain text.
    Active Contributor
    Posts: 27
    Registered: ‎09-25-2008

    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

    Please use plain text.