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;
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
Hartmut Eger
Senior Engineer
Anlagenplanung + Elektotechnik
XING | LinkedIn
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.
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
I just ran a test with your exact original code and it worked with no problem.
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
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?
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.
@salman_abeed wrote:
lineNumber variable value = CWS-1001
That value does not exist in the database you provided.
Can't find what you're looking for? Ask the community or share your knowledge.