Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

3DSketch using Pro-Toolkit

kishorev

New member
Hello,


I am trying to create a 3D Sketch,Textwith Pro-Toolkit.It is Cosmotic>Sketch>Text form the Pro-Engineer option,I am reproducing with Pro-Toolkit application.I am getting the problem in the section,ProSectionSolve() API returns -1 value.


ProError UserSectionBuild(ProSection section, ProSelection *sketch_refs,ProSelection *proj_ents)
{


//ProSelection *proj_ents;
int status, i, num_errors, err_counter, proj_ids[2];
int ctr_line_id, rt_line_id, lt_line_id,lt_par_line_id,top_line_id,top_par_line_id,text_3 d_id;
int upper_arc_id, lower_arc_id, ent_id[1], c_ent_id[2], proj_ent_id[2];
int ll_dim_id, tl_dim_id, ua_dim_id, la_dim_id, cl_dim_id, proj_dim_id[2];
ProWSecerror sec_errors;
Pro2dLinedef line;
Pro2dClinedef c_line;
Pro2dLinedef *left_linedef, *btm_linedef;
ProSectionPointType pt_type[1], proj_pt_type[2];
Pro2dArcdef arc;
Pro2dPnt place_pnt;

ProMsg wmsg;
char msg[PRO_PATH_SIZE];
double offsets[2],element[2];
Matrix_data matrix_data;
int row_col[2];
int *row_line_id;
int *col_line_id;


Pro2dTextdef text_3d;
char text_str[PRO_COMMENT_SIZE];
FILE *fp;



fp=fopen("section.txt","w+");



strcpy(text_str,"VKB");








ProStringToWstring(msgfile, "msg_ug3dsketch.txt");



for (i = 0; i < 2; i++)
{
status = ProSectionEntityFromProjection(section, proj_ents, &proj_ids);

if (status != PRO_TK_NO_ERROR) return status;
}


status = ProSectionEntityGet(section, proj_ids[0], (Pro2dEntdef **)&btm_linedef);

if (status != PRO_TK_NO_ERROR) return status;


for (i = 0; i < 2; i++)
{
matrix_data.x_axis[0] = btm_linedef->end1;
matrix_data.x_axis[1] = btm_linedef->end2;
matrix_data.x_axis[2] = 0.0;
}

status = ProSectionEntityGet(section, proj_ids[1], (Pro2dEntdef **)&left_linedef);

if ( status != PRO_TK_NO_ERROR )
return status;

for (i = 0; i < 2; i++)
{
matrix_data.y_axis[0] = left_linedef->end1;
matrix_data.y_axis[1] = left_linedef->end2;
matrix_data.y_axis[2] = 0.0;
}



status = ProSectionLocationGet(section, matrix_data.sk_mtrx);

if (status != PRO_TK_NO_ERROR) return status;


status = ProSelectionCopy(sketch_refs[0], &(matrix_data.sk_plane));

if (status != PRO_TK_NO_ERROR) return status;


status = UserCreateTrfMatrix(&matrix_data);

if (status != PRO_TK_NO_ERROR) return status;


status = UserSelectOffsetDistances(offsets);

if (status != PRO_TK_NO_ERROR) return status;



// For Creation of text


text_3d.type = PRO_2D_TEXT;
text_3d.first_corner[0] = 1.00;
text_3d.first_corner[1] = 2.00;


text_3d.second_corner[0] = 1.00;
text_3d.second_corner[1] = 2.20;


ProStringToWstring(text_3d.string,text_str);


ProStringToWstring(text_3d.font_name,"font3d");




ProUtil2DPointTrans(matrix_data.sec_trf, text_3d.first_corner, text_3d.first_corner);
ProUtil2DPointTrans(matrix_data.sec_trf, text_3d.second_corner, text_3d.second_corner);


status = ProSectionEntityAdd(section, (Pro2dEntdef*)&text_3d, &text_3d_id);
fprintf(fp,"ProSectionEntityAdd:%d\n",status);

if (status != PRO_TK_NO_ERROR) return status;





proj_ent_id[0] = proj_ids[1];
proj_ent_id[1] = text_3d_id;
proj_pt_type[0] = PRO_ENT_WHOLE;
proj_pt_type[1] = PRO_ENT_START;
place_pnt[0] = offsets[1];
place_pnt[1] = 0.5;


ProUtil2DPointTrans(matrix_data.sec_trf, place_pnt, place_pnt);


status = ProSecdimCreate(section, proj_ent_id, proj_pt_type, 2, PRO_TK_DIM_LINE_POINT, place_pnt, &cl_dim_id);
fprintf(fp,"ProSecdimCreate:%d\n",status);



proj_ent_id[0] = proj_ids[0];
proj_ent_id[1] = text_3d_id;
proj_pt_type[0] = PRO_ENT_WHOLE;
proj_pt_type[1] = PRO_ENT_START;
place_pnt[0] = offsets[1] / 2.00;
place_pnt[1] = offsets[0] + 0.1;


ProUtil2DPointTrans(matrix_data.sec_trf, place_pnt, place_pnt);


status = ProSecdimCreate(section, proj_ent_id, proj_pt_type, 2, PRO_TK_DIM_LINE_POINT, place_pnt, &cl_dim_id);
fprintf(fp,"ProSecdimCreate:%d\n",status);



proj_ent_id[0]= text_3d_id;
proj_ent_id[1]= text_3d_id;
proj_pt_type[0] = PRO_ENT_START;
proj_pt_type[1] = PRO_ENT_END;
place_pnt[0] = offsets[1]-0.05;
place_pnt[1] = 2.00+0.1;


ProUtil2DPointTrans(matrix_data.sec_trf, place_pnt, place_pnt);


status = ProSecdimCreate(section, proj_ent_id, proj_pt_type, 2, PRO_TK_DIM_PNT_PNT, place_pnt, &cl_dim_id);
fprintf(fp,"ProSecdimCreate:%d\n",status);





status = ProSecdimValueSet(section, cl_dim_id, 0.20);
fprintf(fp,"ProSecdimValueSet:%d\n",status);





status = ProSecerrorAlloc(&sec_errors);
fprintf(fp,"ProSecerrorAlloc:%d\n",status);


// status=ProSectionAutodim(section,&sec_errors);



if (status != PRO_TK_NO_ERROR)
return status;


status = ProSectionSolve(section, &sec_errors);
fprintf(fp,"ProSectionSolve:%d\n",status);


if (status != 0)
{


return status;
}


status = ProSectionRegenerate(section, &sec_errors);
fprintf(fp,"ProSectionRegenerate:%d\n",status);


if (status != 0)
{

return status;
}

status = ProSelectionFree(&(matrix_data.sk_plane));
fprintf(fp,"ProSelectionFree:%d\n",status);

fclose(fp);


return(status);
}





Plz let me know what was wrong in my sample.I checked with the ProSectionAutodim() API it works fine.Where as i try to add dimensions using the API ProSecdimCreate() API ,ProSectionSolve() return -1.I could not able to guess what was wrong.


With regards,


Kishore v
 

Sponsor

Back
Top