Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hi
I am able to merge two drawing file but facing issue with replace solid model.
I have to replace solid model of added drawing.
I want to set Root Model to Each Drawing Sheet.
Please find below code.
//Retrieve Model and Its Main Assembly
ProName _objFileName = L"imd253803.drw";
status = ProMdlRetrieve (_objFileName, PRO_MDL_DRAWING, &objCurrentMdl);
//Set it as current model
ProSolid objSolid;
status = ProDrawingCurrentsolidGet((ProDrawing)objCurrentMdl, &objSolid);
//Get Name of the solid
ProName objSolidName;
status = ProMdlNameGet (objSolid, objSolidName);
//Add Another Drawing
ProName objfilename_Next = L"imd253803_001a.drw";
ProMdl objCurrentMdl_Next;
status = ProMdlRetrieve (objfilename_Next, PRO_MDL_DRAWING, &objCurrentMdl_Next);
//Merge Second Drawing into Main
status = ProDrawingMerge((ProDrawing)objCurrentMdl, (ProDrawing)objCurrentMdl_Next);
ProMdl objCurrentMdl_Next_Again;
status = ProMdlRetrieve (objfilename_Next, PRO_MDL_DRAWING, &objCurrentMdl_Next_Again);
int Sheet_Next;
status = ProDrawingCurrentSheetGet((ProDrawing)objCurrentMdl_Next_Again, &Sheet_Next);
status = ProDrawingCurrentSheetSet((ProDrawing)objCurrentMdl_Next_Again, Sheet_Next);
ProSolid objSolid_Next;
status = ProDrawingCurrentsolidGet((ProDrawing)objCurrentMdl_Next_Again, &objSolid_Next);
ProName objSolidName_Next;
status = ProMdlNameGet (objSolid_Next, objSolidName_Next);
status = ProDrawingCurrentsolidSet((ProDrawing)objCurrentMdl_Next_Again, objSolid);
status = ProDwgSheetRegenerate((ProDrawing)objCurrentMdl_Next_Again, Sheet_Next);
status = ProDrawingSolidReplace((ProDrawing)objCurrentMdl_Next_Again, objSolid, objSolid_Next, PRO_B_TRUE);
Please do the needful.
The difficulty here is when the documentation of ProDrawingMerge says the handle to the second drawing is lost, what it means is: If you have two drawings in session, D1 and D2, and you call ProDrawingMerge(D1, D2), then afterwards you have one drawing in session, called D1, which has the original D1 plus the sheets from D2. The D2 drawing in memory is destroyed and all its data merged into D1. So when you ProMdlRetrieve D2 after, you are getting a new copy of D2 loaded from disk. Changing the solid of this drawing does not do much useful for your final product.
I believe your intent is to take a drawing D1 of various instances of a part P1, and a drawing D2 of P1, and you wish to add to D1 a sheet which is 'D2, but P1 replaced by instance INST1 of P1'. To do this, having D1 in memory: retrieve D2, replace P1 -> INST1<P1> in D2, then ProDrawingMerge(D1,D2). Then, D1 has the desired content.
I hope this is helpful!
Hi Matthew,
Thanks for your answer but It seems model is not update in second sheet.
Please find below code.
//D1 Drawing
status = ProMdlRetrieve( L"D1.drw", PRO_MDL_DRAWING , &obj_D1_Drawing);
//D1 Drawing's Solid Handler
status = ProDrawingCurrentsolidGet((ProDrawing)obj_D1_Drawing,&obj_D1_Drawing_Solid); //Output : D1 Drawing
//D2 Drawing
status = ProMdlRetrieve( L"D2.drw", PRO_MDL_DRAWING , &obj_D2_Drawing);
//D2 Drawing's Solid Handler
status = ProDrawingCurrentsolidGet((ProDrawing)obj_D2_Drawing,&obj_D2_Drawing_Solid); //Output : D2 Drawing
//Merge
status = ProDrawingMerge((ProDrawing)obj_D1_Drawing, (ProDrawing)obj_D2_Drawing);
//Retrive Merge Drawing - D1
status = ProMdlRetrieve(L"D1.drw",PRO_MDL_DRAWING, &obj_D1_Drawing);
//Save
status = ProMdlSave((ProDrawing)obj_D1_Drawing);
//Now I have to replace all drawing sheet handler with "D1 Drawing"for that I am getting error.
//I am using below approach for replace handler to all sheet
status = ProDrawingSolidAdd((ProDrawing)obj_D1_Drawing,obj_D1_Drawing_Solid);
status = ProDrawingCurrentsolidSet((ProDrawing)obj_D1_Drawing,obj_D1_Drawing_Solid); //Here It is added but not update in drawing sheet..Please suggest
Here in below snap - After merge I want to replace model "Name" in sheet which is in Green Color (D2_Drawing) with D1_Drawing.
Please do the needful.
Hi Ketan,
Thanks for your valuable suggestion....
Okz..I will check and let you know the results...
Your new code does not include a call to ProDrawingSolidReplace on drawing D2, which should be done after ProMdlRetrieve and before ProDrawingMerge.
Hi Matthew,
I have tried your options but still problem is pending...It is not update...
//D1 Drawing | |
ProMdl obj_D1_Drawing; | |
status = ProMdlRetrieve( L"d1_drawing.drw", PRO_MDL_DRAWING , &obj_D1_Drawing); |
//D1 Drawing's Solid Handler | |||
ProSolid obj_D1_Drawing_Solid; | |||
status = ProDrawingCurrentsolidGet((ProDrawing)obj_D1_Drawing,&obj_D1_Drawing_Solid); //Output : D1 Drawing | |||
//D2 Drawing | |||
ProMdl obj_D2_Drawing; | |||
status = ProMdlRetrieve( L"d2_drawing.drw", PRO_MDL_DRAWING , &obj_D2_Drawing); |
//D2 Drawing's Solid Handler | |
ProSolid obj_D2_Drawing_Solid; | |
status = ProDrawingCurrentsolidGet((ProDrawing)obj_D2_Drawing,&obj_D2_Drawing_Solid); //Output : D2 Drawing |
//Add D1 Drawing's Solid Handler into D2 Drawing | |
status = ProDrawingSolidAdd((ProDrawing)obj_D2_Drawing,obj_D1_Drawing_Solid); | |
//Replace D2 Drawing's Solid Handler with D1 Drawing's Solid | |
status = ProDrawingSolidReplace ((ProDrawing)obj_D2_Drawing, obj_D1_Drawing_Solid, obj_D2_Drawing_Solid, PRO_B_TRUE); |
//Merge | |
status = ProDrawingMerge((ProDrawing)obj_D1_Drawing, (ProDrawing)obj_D2_Drawing); |
//Save | |
status = ProMdlSave((ProDrawing)obj_D1_Drawing); |
//Retrive Merge Drawing - D1 | |
status = ProMdlRetrieve(L"d1_drawing.drw",PRO_MDL_DRAWING, &obj_D1_Drawing); |
int n_sheets,count; | |
status = ProDrawingSheetsCount((ProDrawing)obj_D1_Drawing, &n_sheets); |
for (count = 1; count <= n_sheets; count++) | |
{ | |
status = ProDwgSheetRegenerate((ProDrawing)obj_D1_Drawing,count); | |
} |
Hi Ketan,
I have also tried your options but facing same issue...
Please refer above code...