cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

visit dimensions from (assembly) drawing

lgüthle
1-Newbie

visit dimensions from (assembly) drawing

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:

  • open assembly file
  • create new drawing model
  • assembly-model (as one piece/element/whatever) is connected as drawing model

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:

  • traverse through assembly-Model via "ProMdlDependenciesList"
  • for each assembly model run again "ProMdlDependenciesList" (recursion)
  • for each part model, call "ProSolidDimensionVisit"

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:

  • traverse through assembly-Model via "ProMdlDependenciesList"
  • for each assembly model run again "ProMdlDependenciesList" (recursion)
  • for each part model, call "ProDrawingSolidsVisit"

is not working -> "PRO_TK_E_NOT_FOUND"

maybe a function to add all assembly elements as drawing model?

regards


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
1 ACCEPTED SOLUTION

Accepted Solutions

Hello,

Go through below steps:

  • ProDrawingSolidsCollect --> Will help you to identify all solids of drawing file. Find array size and loop through all solids
  • ProSolidDimensionVisit ---> Visit the dimensions of solid
  • ProAnnotationIsShown ---> Use this API into Filter action of above visit. decide whether solid's dim is visible into drawing file or not
  • Below is the list of API to be called into visit action:
    • ProDrawingDimensionViewGet --> Will get handle of view [Note: you will not get -4 here as you filtered in visit filter (ProAnnotationIsShown) that only shown annotations are visited.]
    • ProDrawingViewNameGet ---> Will get name of the view

Let me know this works for you or not.

Regards

Ketan

View solution in original post

6 REPLIES 6

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:

  • ProDrawingSolidsCollect --> Will help you to identify all solids of drawing file. Find array size and loop through all solids
  • ProSolidDimensionVisit ---> Visit the dimensions of solid
  • ProAnnotationIsShown ---> Use this API into Filter action of above visit. decide whether solid's dim is visible into drawing file or not
  • Below is the list of API to be called into visit action:
    • ProDrawingDimensionViewGet --> Will get handle of view [Note: you will not get -4 here as you filtered in visit filter (ProAnnotationIsShown) that only shown annotations are visited.]
    • 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;

}

Top Tags