AutoCAD Plant 3D Forum
Welcome to Autodesk’s AutoCAD Plant 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Plant 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get rowid of from P3dLineGroup table?

12 REPLIES 12
Reply
Message 1 of 13
salman_abeed
488 Views, 12 Replies

How to get rowid of from P3dLineGroup table?

I am trying to create new piping components into the model and want to assign a line that I am reading from excel. I check if a line already exist then try to get the rowid otherwise create a new line and then create a relation.

 

Issue is that query to search existing line is not returning any results. Here is my sample code

 

PlantProject currentProj = PlantApplication.CurrentProject;
PipingProject pipeProj = (PipingProject)currentProj.ProjectParts["Piping"];
DataLinksManager dlm = pipeProj.DataLinksManager;
PnPDatabase db = dlm.GetPnPDatabase();

PnPTable p3dLineGroupTable = db.Tables["P3dLineGroup"];


string lineFilter = string.Format("Number='{0}'", lineNumber);

PnPRow[] rowsLines = p3dLineGroupTable.Select(lineFilter);

int lineRowID = 0;
if (rowsLines.Length > 0)
    lineRowID = rowsLines[0].RowId;

 

12 REPLIES 12
Message 2 of 13
h_eger
in reply to: salman_abeed

@salman_abeed ,

 

rowid is NOT the row number in the DB!
The rowid is used to link information between the tables.
Here is the structure of the Piping DB to study and understand

-

If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).

Hartmut Eger
Senior Engineer
Anlagenplanung + Elektotechnik
XING | LinkedIn

EESignature



Message 3 of 13
salman_abeed
in reply to: salman_abeed

@h_eger thanks for the reply. Can you tell how can I search the ID of exisiting line to create the relation of line with a new component?

 

thanks

Salman

Message 4 of 13
jabowabo
in reply to: salman_abeed

Try this:

string lineFilter = string.Format("\"Number\"='{0}'", lineNumber);

 

Also, it's better practice to search for the Tag rather than Number, as Tag must be unique but Number does not.

Message 5 of 13
salman_abeed
in reply to: salman_abeed

No it still doesn't work. I try with tag as well and also putting field name in quotes but same result. If I try to add the same line again I get the exception 

 

salman_abeed_0-1715641240593.png

 

Message 6 of 13
jabowabo
in reply to: salman_abeed

I just ran a test with your exact original code and it worked with no problem.

Message 7 of 13
salman_abeed
in reply to: salman_abeed

I have attached my ProcessPower.dcf file in the zip format. I also notice in the new project it works fine but then later it starts failing. Not sure if this file alone will be enough. But can you give it a try?

 

thanks

Message 8 of 13
salman_abeed
in reply to: salman_abeed

Sorry I want to attach 3d database ... here is piping

Message 9 of 13
jabowabo
in reply to: salman_abeed

The ProcessPower.dcf you attached is the database for P&ID drawings. Piping.dcf is for 3D. Your code is querying the 3D piping database. Which database rows are you looking for? 

Message 10 of 13
salman_abeed
in reply to: jabowabo

right I attached piping.dcf as well

Message 11 of 13
jabowabo
in reply to: salman_abeed

From what you've provided so far, I can't diagnose the problem. You'll need to provide more details, like variable values at each step, error messages, etc. for more help.

Message 12 of 13
salman_abeed
in reply to: salman_abeed

lineNumber variable value = CWS-1001

Message 13 of 13
jabowabo
in reply to: salman_abeed


@salman_abeed wrote:

lineNumber variable value = CWS-1001


That value does not exist in the database you provided.

jabowabo_0-1715710004100.png

 

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

Post to forums  

Autodesk Design & Make Report