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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

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

AA_10646944
7-Bedrock

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

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++

 

 

 

 

 

 

 

 

9 REPLIES 9
FV
17-Peridot
17-Peridot
(To:AA_10646944)

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

 

 

AA_10646944
7-Bedrock
(To:FV)

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

FV
17-Peridot
17-Peridot
(To:AA_10646944)

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){
AA_10646944
7-Bedrock
(To:FV)

Yes, i have used that API to visit views (status = ProDrawingViewVisit((ProDrawing)Drawing, ViewVisit, (ProViewFilterAction)CheckFlatView, NULL);)

From that (ProVIewFilterAction)CheckFlatView..

 

 

and i have changed the loop for n_views  to    ( for (int j=0; j<n_views; j++)).... Please help me to solve this problem

 

 

Thanks InAdvance

Abdul Aziz

AA_10646944
7-Bedrock
(To:FV)

HI Team,

I am  getting dimension From the  annotations dispaly method. now i want to know how to convert that linear dimesions into ordinate dimensions. What is  the manual approach for this to achieve?

 

linear dimensions are not taking the single base line if iam trying to toggle it ordinate manually.. can you please this as a concern.

HI Team,

I am getting standard dimension from the annotations show () method. now i want to know how to convert those standard dimensions into ordinate dimensions. What is the manual approach for this to achieve?

 

standard dimensions are not taking the single base line if Iam trying to toggle it ordinate manually. can you please take this as a concern.

 

 

the method you have suggested is not suitable for standard to ordinate dimensioning. may be suitable for linear to ordinate. advise me a best way to fit my requirement..

FV
17-Peridot
17-Peridot
(To:AA_10646944)

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(...)

do not use model dimensions.

make drawing linear dimensions and convert them to ordinate.

if needs to be, model dimensions could be queried for attachments and positions and the acquired data could be used in making drawing dimensions.

make sure the config.pro option related to storing drawing dimensions in a drawing file was set to yes.

HIH

AA_10646944
7-Bedrock
(To:FV)

can i use the ProDimensionAutoOrdinateCreate()  API instead of converting standard dimension into linear ,linear to ordinate?

 

Please let me know how to get the surface/regions from the view which is selected..

 

thanks InAdvance

Abdul Aziz

FV
17-Peridot
17-Peridot
(To:AA_10646944)

I would avoid using ProDimensionAutoOrdinateCreate(...)

The function takes an array of parallel surfaces and arbitrary decides what edges to be dimensioned... There is no way to define a 'dimensioning strategy' to pass to this function... Try to use its UI counterpart while in a drawing and you very likely would spend more time deleting and rearranging auto dimensions as you would spend making necessary dimensions one by one

Top Tags