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.

Sketched Features ...

David_Hyper

New member
Hello,



i'd like to have a very very simple example on how to create an extruded sketched feature, not the first feature one,with the section created in code,NO user interaction please. Just a cube with 4 lines.

I am able to create a section and all, but when i call the ProFeatureRedefine it always ask the user to complete it by selecting the sketching plane, even if i get the PRO_E_SKETCHER from the feature tree and set it with my section. Also, when I try to regenrate or solve my section, it awlways gives me an error.

===================================================
path_items[0].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
path_items[0].path_item.elem_id = PRO_E_STD_SECTION;
path_items[1].type = PRO_ELEM_PATH_ITEM_TYPE_ID;
path_items[1].path_item.elem_id = PRO_E_SKETCHER;


status = ProElempathAlloc(&path);
status = ProElempathDataSet(path, path_items, 2);
status = ProElemtreeElementGet(created_elemtree, path, &sketch_element);
status = ProElementValueGet(sketch_element, &value);
status = ProValueDataGet(value, &value_data);


// retrieve section
pSection = (ProSection*)(&value_data.v.p);

// allocate the section .. add lines .. regen .. solve .. etc

//Redefining the feature to make it complete.
opts[0] = PRO_FEAT_CR_DEFINE_MISS_ELEMS;
status = ProSelectionAsmcomppathGet(model_sel, &comp_path);
status = ProFeatureRedefine(&comp_path, &feature, created_elemtree, opts, 1, &errors);
===================================================

What am i doing wrong ?

PS: all the PRO_E_STD_SEC_SETUP_PLANE elementsare set to valid datum planes.


Thx a lot

David
Edited by: David_Hyper
 
This is a very good question! I am also having a lot of problems with the creation of sketched features.


Documentation examples on pro/eng are very big for nothing! you get lost into the code and forget what you were looking for! I never got to anything trought all the examples!



I really need some Pros answers!


thanks in advance to anyone who`s gonna help me..
 
Ok i have found what i was doing wrong

first of all you dont have to allocate the section for the conventionnal extruded feature since it is already allocated for you.


Retrieve the section the same way i did in my first post and add items to your section like this :
=======================================================



// add a circle in this section
Pro2dCircledef circle;
int circle_id;
circle.type = PRO_2D_CIRCLE;
circle.center[0] = circle.center[1] = 0.0;
circle.radius = 5.0;
status = ProSectionEntityAdd(Section,(Pro2dEntdef*)&circle, &circle_id);


// add the 2 ref planes as projection entities
int entity_id;
status = ProSectionEntityFromProjection(Section, sketch_refs[0], &entity_id);
status = ProSectionEntityFromProjection(Section, sketch_refs[1], &entity_id);


// set epsilon
status = ProSectionEpsilonSet(Section, 0.1);


// autodim the section
ProWSecerror sec_errs;
status = ProSecerrorAlloc(&sec_errs);
status = ProSectionAutodim(Section, &sec_errs);
status = ProSecerrorFree(&sec_errs);


=======================================================


The most important thing here are the calls to the ProSectionEntityFromProjection functions (this is what i was doing wrong). the "sketch_refs" must be valid datum planes or surfaces other than the sketching surface.

For example, in the feature tree, my PRO_E_STD_SEC_PLANE value is the FRONT datum plane, my PRO_E_STD_SEC_PLANE_ORIENT_REF is the RIGHT datum plane.

My sketch_refs[0] is the RIGHT datum plane and my sketch_ref[1] is the TOP datum planes.

To retrieve the datum planes ive used the ProSolidFeatVisit, filtered on PRO_FEAT_DATUM, in the action ive retrieved the name of the datum located in the PRO_E_STD_FEATURE_NAME. When I had the name, int the action function,ive called ProFeatureGeomitemVisit with the PRO_SURFACE to retrieve the planes as ProGeomitem. When you have the planes as ProGeomitem its easy to select them in ProSelection objects, just like that:
ProSelection SelectionRef;
ProSelectionAlloc(NULL, (ProModelitem*)pPlaneAsGeomitem, &SelectionRef);

David
 
David_Hyper, thank you for good explanation. I had the same troubles and your post was very helpful for me.
 
Yeah!! Thanks David_Hyper!!


..just returned from my honeymoon in jamaica, checked my emails and tried your example. Everything works perfectly for me!! We were 4 guys here trying to solve a design probleme with programming and with your help, I'm the one who solved it! I can now apply to be this team's supervisor! Great thanks to you David_Hyper!


Best regards,


Zmon10!
 

Sponsor

Back
Top