Skip to main content
7-Bedrock
April 16, 2023
Question

how to create automatic ordinate dimensions for the falt view in creo drawing using Toolkit C++

  • April 16, 2023
  • 1 reply
  • 3287 views

Team, 

 

I Would like to Create a ordinate dimensions automatically, after finding the flat view in  drawing...

 

1. code need to find out the Flat View is present or not

2. need to create automatic ordinate dimensions for the view

 

 

Please help me to solve my problem

platform: CREO  4.0 M140 / toolkit C++

 

 

 

 

 

 

 

 

1 reply

17-Peridot
April 20, 2023

a general answer to a general question...

 

In order to create a drawing ordinate dimension one would need to create a drawing linear dimension with ProDrawingDimensionCreate(...) and to convert that dimension to the ordinate one with ProDrawingOrdbaselineCreate(...) and ProDrawingDimToOrdinate(...)

 

The generic approach for finding a specific drawing view is to use ProDrawingViewVisit(...) function and to query each visited view for app specified data, whatever that data might be. When app's data would match view's data the visiting should stop...

 

HIH

 

 

7-Bedrock
May 8, 2023

Hi team,

I have used the sample code (Article - CS277961 - The sample code of API ProDrawingDimensionCreate() (ptc.com)) to create the  Dimension for the drawing... 

the dimensions are creating for all the views, but i need the dimensions for the only flat view once views are filtered.

even after filtering the specific view ,code is taking the other attachements and creating the dimension,

is there any  other API that is more specific with drawing view instead of Drawing completely?

 

correct the line of where iam missing for specific flat view attachments.

 

(fyr)myCode:

ProError CheckFlatView(ProDrawing Drawing, ProAppData data) {
ProError status;
ProViewType Type;
ProName viewName;

ProView *views = NULL;
int m;
int n_views = 0;

char cViewName[99];
ProViewType* General;
ProSolid solid;

status = ProDrawingViewsCollect(Drawing, &views);
if (status == PRO_TK_NO_ERROR){

status = ProArraySizeGet(views, &n_views);
for (int j = 0; j <= n_views; ++j){

status= ProDrawingViewSolidGet(Drawing, views[j], &solid);
char cMdlName[99];
ProName MdlName;
status = ProMdlMdlnameGet(solid, MdlName);
ProWstringToString(cMdlName, MdlName);
string sModelName = cMdlName;

// if (cMdlName != nullptr && "FLAT" != nullptr && strstr( "FLAT", cMdlName) != 0){
char *p =strstr(cMdlName,"FLAT");
if (p) {

 

// if (strstr(cMdlName, "FLAT") == NULL) {
string sMessage = "\n View is flat:";
Log::PrintMessage("DrawingInformation.txt", sMessage);


ProModelitem csys_item_1;
status = ProModelitemInit((ProMdl)solid, 68, PRO_CSYS, &csys_item_1); //68 is item id
status = ProDrawingViewInit((ProDrawing)Drawing,1, &views[j]); //8 is drawing view id

ProSelection* p_selection;
ProView *views = NULL;
status = ProArrayAlloc(2, sizeof(ProSelection), 1, (ProArray*)&p_selection);
status = ProSelectionAlloc(NULL, &csys_item_1, &p_selection[0]);

ProModelitem csys_item_2;
status = ProModelitemInit((ProMdl)solid, 8, PRO_CSYS, &csys_item_2); //8 is item id
status = ProSelectionAlloc(NULL, &csys_item_2, &p_selection[1]);
status = ProSelectionViewSet((ProView)views, &p_selection[1]);
ProDimSense *sense_arr;
status = ProArrayAlloc(2, sizeof(ProDimSense), 1, (ProArray*)&sense_arr);
sense_arr[0].type = PRO_DIM_SNS_TYP_PNT;
sense_arr[0].sense = 3;
sense_arr[0].angle_sense.is_first = PRO_B_FALSE;
sense_arr[0].angle_sense.pic_vec_dir = PRO_B_FALSE;
sense_arr[0].angle_sense.should_flip = PRO_B_FALSE;
sense_arr[0].orient_hint = PRO_DIM_ORNT_NONE;

sense_arr[1].type = PRO_DIM_SNS_TYP_PNT;
sense_arr[1].sense = 3;
sense_arr[1].angle_sense.is_first = PRO_B_FALSE;
sense_arr[1].angle_sense.pic_vec_dir = PRO_B_FALSE;
sense_arr[1].angle_sense.should_flip = PRO_B_FALSE;
sense_arr[1].orient_hint = PRO_DIM_ORNT_NONE;

ProMouseButton btn;
ProVector loc, csys_3dpos;
if (ProMousePickGet(PRO_ANY_BUTTON, &btn, loc) != PRO_TK_NO_ERROR)
return PRO_TK_GENERAL_ERROR;

ProDimension dimension, vbase_dim;
ProDimAttachment *attachment_arr;
status = ProArrayAlloc(2, sizeof(ProDimAttachment), 1, (ProArray*)&attachment_arr);

status = ProSelectionCopy(p_selection[0], attachment_arr[0]);
status = ProSelectionCopy(p_selection[1], attachment_arr[1]);

status = ProDrawingDimensionCreate((ProDrawing)Drawing, attachment_arr, sense_arr, PRO_DIM_ORNT_VERT, loc, PRO_B_TRUE, &dimension);
if (status == PRO_TK_NO_ERROR)
{

status = ProSelectionViewGet(p_selection[0], &views[j]);
status = ProAnnotationShow(&dimension, NULL, views[j]);
status = ProArrayFree((ProArray*)&sense_arr);
}

}
else {
string sMessage = "\n wrong call:";
Log::PrintMessage("DrawingInformation.txt", sMessage);
}

 

}
}


return status;
}

 

 

 

 

Thanks InAdvance

Abdul Aziz

17-Peridot
May 8, 2023

to OP: you would need to collect views relevant to your task with ProDrawingViewVisit(...) prior to running dimensioning code...

 

on a side note: the following line advances the index past the last element of the array...

for (int j = 0; j <= n_views; ++j){