Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
hello,
is it possibile to visit dimensions from a assembly drawing and get information about from which PART the dimensions is from? As far as I understand Creo it works as following:
If I try to visit dimensions I found "ProDrawingDimensionVisit" for reference (manually added) dimensions in the drawing and "ProDrawingSolidsVisit" for the dimensions from the drawing model. But both methods dont deliver any information from which part the dimension is driven from.
E.g. just for assembly model (NOT drawing) it works just fine if I do:
I cant use the same in drawing mode because I need some extra information (like in which view the dimension is) so I have to use "ProDrawingSolidsVisit". But:
is not working -> "PRO_TK_E_NOT_FOUND"
maybe a function to add all assembly elements as drawing model?
regards
Solved! Go to Solution.
Hello,
Go through below steps:
ProDrawingViewNameGet ---> Will get name of the view
Let me know this works for you or not.
Regards
Ketan
Hi,
I am able to find view details also for the dimension created in assembly. Only assumption I made is that dimension created into assembly must be visible into drawing file as well.
If still you are not able to get all details, I can look into your code snippet if you share it here.
Regards
Ketan
Ketan Lalcheta schrieb:
Only assumption I made is that dimension created into assembly must be visible into drawing file as well.
What do you mean with "must be visible into drawing file"?
here are my code snippets.
Derive Dimensions from 3D ASSEMBLY (working)
ProMdl mdl;
ProError status;
status = ProMdlCurrentGet(&mdl);
traverseModel(mdl);
traverseModel(ProMdl mdl){
int i, n_mdl;
ProModel *model_list;
wchar_t name[80];
wchar_t type[10];
status = ProMdlDependenciesList (mdl, &model_list, &n_mdl);
for( i=0; i<n_mdl; i++ ){
wcscpy_s(name, 80, model_list[i].name);
wcscpy_s(type, 10, model_list[i].type);
if(wcsncmp(model_list[i].type, assembly,3) == 0 ){
status = ProMdlRetrieve(model_list[i].name, PRO_MDL_ASSEMBLY, &mdlTemp);
traverseCounter++;
traverseModel(mdlTemp);
}
if(wcsncmp(model_list[i].type, part,3) == 0 ){
if(traverseCounter==0){
getDimensions(mdl);
} else {
status = ProMdlRetrieve(model_list[i].name, PRO_MDL_PART, &mdl);
getDimensions(mdl);
}
}
}
getDimensions(ProMdl mdl){ProBoolean refdim = PRO_B_FALSE;
ProDimension *p_dims;
status = ProArrayAlloc( 0, sizeof(ProDimension), 1, (ProArray*)&p_dims);
status = ProSolidDimensionVisit( (ProSolid)mdl, refdim, (ProDimensionVisitAction)DimVisitAction, (ProDimensionFilterAction)NULL, (ProAppData)&p_dims);
status = ProArrayFree( (ProArray*)&p_dims );
}
Attempt to derive dimensions with view details (not working):
ProMdl mdl;
ProError status;
status = ProMdlCurrentGet(&mdl);
traverseModel(mdl); <- the same as in 3D method but calling different getDimensions() method
getDimensionsDrawing(ProMdl mdl){ProDimension *p_dims;
status = ProArrayAlloc( 0, sizeof(ProDimension), 1, (ProArray*)&p_dims);
/* status for ProDrawingSolidsVisit = -4
ProSolidDimVisitAction calls ProSolidDimensionVisit
*/
status = ProDrawingSolidsVisit((ProDrawing)mdl, ProSolidDimVisitAction, NULL, (ProAppData)&p_dims); <- ERROR = -4
status = ProArrayFree( (ProArray*)&p_dims );
}
Second attempt to derive dimensiosn with view details (not working as well):
ProMdl mdl;
ProSolid *solids;
status = ProArrayAlloc( 0, sizeof(ProDimension), 1, (ProArray*)&solids);
status = ProMdlCurrentGet(&mdl);
ProDrawingViewVisit((ProDrawing)mdl,ProTestViewVisitAction, NULL, (ProAppData)&solids);
ProArraySizeGet( solids, &numberSolids );
ProDimension *p_dims;
status = ProArrayAlloc( 0, sizeof(ProDimension), 1, (ProArray*)&p_dims);
for( i=0; i<numberSolids; i++ ){
ProDrawing temp = (ProDrawing)&solids[i];
status = ProMdlTypeGet((ProMdl)&solids[i], &mdltype);
status = ProDrawingSolidsVisit(temp, ProSolidDimVisitAction, NULL, (ProAppData)&p_dims);
}
ProTestVewVisitAction(ProDrawing drawing, ProView view, ProError filterstatus, ProAppData data){
.... status = ProDrawingViewSolidGet (drawing, view, &solid);
...
ProArrayObjectAdd((ProArray*)data, PRO_VALUE_UNUSED, 1, &solid);
}
Thanks for looking into my code!!
best regards
Luis
Hello,
Go through below steps:
ProDrawingViewNameGet ---> Will get name of the view
Let me know this works for you or not.
Regards
Ketan
I woud call:
ProDimension *p_dims;
status = ProArrayAlloc( 0, sizeof(ProDimension), 1, (ProArray*)&p_dims);
ProSolidDimensionVisit( solids[i], PRO_B_FALSE, (ProDimensionVisitAction)DimVisitAction, (ProDimensionFilterAction)visibleFilter, (ProAppData)&p_dims);
But if I do so:
In Filter action: where do i get the mdl from?
ProError visibleFilter(ProDimension *dim, ProAppData appdata){
ProError status;
ProBoolean isShown;
status = ProAnnotationIsShown((ProAnnotation*)&dim, mdl?, &isShown); <--- where do I get the mdl from?
return status;
}
In Visit action: where do i get the ProDrawing from?
ProError DimVisitAction (ProDimension *dimension, ProError filter_status, ProAppData data) {
ProDrawingDimensionViewGet(drawing, dim, view);
ProDrawingViewNameGet(drawing, view, name);
}
So instead of parameter p_dims I have do give an arrayy of solids as ProAppData?
you can get the handler of drawing from mdlcurrentget.
ok. For Drawings with a PART-file as drawing model it works but not for drawings with an ASSEMBLY-file as drawing model.
For a drawing with an assembly-file as drawing model i get at "ProSolidDimensionVisit" -4 as return (it is not even visiting the DimDrwVisitAction-method in debug mode).
My Code looks like this (I check for isShown in VisitAction, not in the FilterAction):
ProSolid *solids;
status = ProArrayAlloc( 0, sizeof(ProDimension), 1, (ProArray*)&solids);
ProDrawingSolidsCollect((ProDrawing)mdl, &solids);
int numberSolids = 0;
int i;
status = ProArraySizeGet( solids, &numberSolids );
ProDimension *p_dims;
status = ProArrayAlloc( 0, sizeof(ProDimension), 1, (ProArray*)&p_dims);
for( i=0; i<numberSolids; i++ ){
status = ProSolidDimensionVisit( solids[i], PRO_B_FALSE, (ProDimensionVisitAction)DimDrwVisitAction, (ProDimensionFilterAction)NULL, (ProAppData)&p_dims);
}
ProError DimDrwVisitAction (ProDimension *dimension, ProError filter_status, ProAppData data) {
ProDimension **dims = (ProDimension**)data;
ProDimension cur_dim;
ProMdl mdl;
ProBoolean isShown;
ProError status;
cur_dim.owner = dimension->owner;
cur_dim.id = dimension->id;
cur_dim.type = dimension->type;
status = ProMdlCurrentGet(&mdl);
status = ProAnnotationIsShown((ProAnnotation*)dimension, (ProDrawing) mdl, &isShown);
if(isShown){
ProArrayObjectAdd((ProArray*)dims, PRO_VALUE_UNUSED, 1, &cur_dim);
}
return status;
}