Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hello
Creating a hole feature on part using toolkit. Placement of hole is defined by end user using GUI. Total three placement surfaces and two offset distances are provided by user as input. What we need to check is whether hole to be created will remove material or it will be located outside of the part boundary?
Main focus area for me is to identify what sign (+/-) should be used for offset distance provided by user in order to ensure material removal.
Feel free to ask in case of any query.
Regards
Ketan
Hi!
It largely depends on the specific task you want to accomplish.
Until more experienced answers, I will provide 3 quick, dirty and dumb solutions.
#1:
If the task is to find whether the intersecting point of the axis of hole and placement plane is within the runtime boundaries of the placement surface then maybe take a look at TestExtObj.c to get some clues.
(Please be aware that everything seems overcomplicated in the tk docs, but there's a reason for it:
Creo is capable of handling not planar surfaces also, drilling through multiple volumes of different parts, etc.
So it seems complicated if a man just wants to drill a hole into a planar surface, but later on with more complicated surfaces this added complexity, will benefit us greatly.)
#2:
Maybe use rays for interference computing.
#3:
If you just want this for short-term testing purposes, then use the lumberjack solution: create the feature, chek if it fails, on failure get the element tree, modify value, regen, check
(yes it is horrible, but sometimes its necessary to create instant-deadd features because the underlying geommath in c is in the core of creo, and we can "access" it only in this rude way. For example, a sketch driven extrude must be first created, then getting its tree and adding the section handle, if I know correctly.)
If these methods don't suit you(or you find them too dumb), then I would start by reading through the ProSurface.h and ProSolid.h (or maybe the interference checkers etc.), maybe you will find a function which is more suited to your needs.
Cheers,
csaba
Thank you so much for your detailed response on this...
We would not like to go with #3 as of now. For #1, I am yet to explore file in detail.
Regarding #2, we also though to find a point on surface and pass ray to identify whether it intersect with surfaces of part or not. We are not able to find how to come up with start point of ray passing (This is nothing but actual intersection of hole axis with primary placement reference). How to find point on surface with offset value provided by user on placement surface is making us confuse now.
Any idea how to travel on surface based on two different references at specific distance?
Hi!
Until you can get more experienced answers:
I might not understand the question, but given the user input, you should be able to create for instance the point (Its 3 DoFs are covered by user) and then you can use its data.
(Also, I must mention that coordinate systems mess up things a bit. In code, you have to always keep in mind which one are you using. Maybe we want asm's coordinatesys feature, but you can imagine, that if we're drawing on the screen, or we're doing something on a drawing we need to keep in mind the transformations.)
Other helpful files: TestSolid.c, AutoAxis.c (<-this one is actually awesome), ProSolid.h, User Guide's section dealing with features (their respective header files hold data)
Cheers,
Csaba
Correct. With three datum planes and offset distance provided by user, I can calculate / interpret point on surface in Creo. Not able to proceed further with API to come up with this point through toolkit code
Hi!
You can always generate features using toolkit.
protk_appls->pt_userguide->ptu_featcreat
These files are referenced in the user guide's appropriate chapters for feature creation, so you get a nice humanize description also from the user guide.
There you will find a vast number of examples for almost all features.
(Basically you assign values to a tree-like data structure, and then let Creo do the heavy-lifting)
Cheers,
csaba
I guess you misunderstood me. Let me make it more clearer. I am able to create different fetaures using toolkit. What i need to ensure before feature creation is that whether hole feature will remove material or not. For that, I decided to go with ray method. For ray method to execute, one need to calculate start point which I am not able to find out using API
Should you have any query, please feel free to write.
Hi!
I was referring to point creation. From the inputs you can create the possible points (datum points, or even csys).
I wrote points, because of the undetermined status of the directions.
If you have a feature point then you get coords, also, if it is a feature then maybe ProSelectionWithOptionsDistanceEval (I think with PRO_B_FALSE it should treat the surface as "non-infinite").
You can also calculate it, but its messier, because you have to get the surfacedata.
Cheers,
csaba
P.S.: Be aware, that this whole issue depends on how you formulate the problem.
I mean the point-calc driven easy solution will treat creating a hole at the exact edge of the thing as a correct solution, because we are checking only a point, and not the resulting geometry. (but pro of it is that this way it's more lightweight).
It would also not raise any alarms if the thread goes outside etc, because we are using a lightweight mathematical model for the problem.
The other end of the spectrum is the other solution by trying to generate the hole, then checking for failure.
(Visual explanation can be maybe a udf insert. You specify the params, it will try to generate, and fail. It will know its status only if it tries the generation.)
Hi!
UG->"Element Trees Datum Features" gives all the info for feature data trees.
UgGeneralPointCreate.c also provides example for point.
Cheers,
csaba
Hi,
What I was trying failed. I tried to follow your steps but could not get below:
Calculate a dot product between normal vector of the first offset plane and a unit vector constracted between the first offset plane pick location to the placement surface pick location and do the same for the second offset plane - this will determine the signs for the offset distances.
I do have "normal vector of the first offset plane". How to find "a unit vector constracted between the first offset plane pick location to the placement surface pick location". Once I will get second vector, I will be able to do dot product.
Sounds good. Actually I am not able to understand how to proceed with unit vector calculation.
Attached is the code snippet for hole placement surface user has provided. Same operations I have performed for other two user selected placement references.
Regards
Ketan
Attaching another Code snap for secondary references.
Attached is code for your easy reference. In code, I have used firstly API RefToSel as all user selected data in my entire solution is stored as ProReference. How to go with unit vector is stopping me now.
Something like this should work. This is C style. In a production code one should be using std::transform or boost uBLAS to keep things neat.
namespace
{
ProError SignEvaluator(
const ProPoint3d & objSelPointPrimaryRef,
const ProPoint3d &objSelPointSecondaryRef_1,
const ProVector & objvectNormalSecondaryRef_1,
ProVector &unit_vector, int &sign)
{
double length = 0;
ProVector tmp_vect = {'\0'};
for( int i = 0; i < sizeof(objSelPointPrimaryRef)/sizeof(objSelPointPrimaryRef[0]); ++i)
{
tmp_vect[i] = objSelPointPrimaryRef[i] - objSelPointSecondaryRef_1[i];
}
double length_sqr = 0;
for( int i = 0; i < sizeof(objSelPointPrimaryRef)/sizeof(objSelPointPrimaryRef[0]); ++i)
{
length_sqr += tmp_vect[i] * tmp_vect[i];
}
if( length_sqr < 1e-6)
return PRO_TK_E_NOT_FOUND;
double length = ::sqrt(length_sqr);
for( int i = 0; i < sizeof(objSelPointPrimaryRef)/sizeof(objSelPointPrimaryRef[0]); ++i)
{
unit_vector[i] = tmp_vect[i]/length;
}
double dot = 0;
for( int i = 0; i < sizeof(objSelPointPrimaryRef)/sizeof(objSelPointPrimaryRef[0]); ++i)
{
dot += unit_vector[i] * objvectNormalSecondaryRef_1[i];
}
if( ::abs(dot) < 1e-6)
return PRO_TK_BAD_INPUTS;
if( dot < 0)
sign = -1;
else
sign = 1;
return PRO_TK_NO_ERROR;
}
}
First of all visit the surfaces of your hole feature, if you have none, ups that may a failure. Next you need cylindrical surfaces. Don’t forget that 2 sided edges have on other direction (clock wise and counter clock wise, for a cylinder with a cylindrical hole on the same axis, check the 4 arc edges, of the surface) for cuts and material added. Based on the direction the normal vector differ for the arc.
In a Creo Parametric solid, each surface contains a list of contours, and each contour contains a list of edges. The edges in a contour form a closed loop, and are ordered such that following the edges keeps the surface on the right. External contours go clockwise, and internal contours go counterclockwise.
is it super important for efficiency reasons to verify this prior to making the feature? if you add the hole feature in it'd be pretty logical to test surface area of the primary placement surface or perhaps if the parts are not super complex, mass props obviously changes downwards when you add a hole and you could also inspect the message log which i beleive will complain about unattached features. then if the act appeared to not do anything then flip the dims. i guess though thinking out loud you have 4 potential options for the 2 offset dims (++,+-,-+,--) not sure how you would choose which one is the most logical.
Can't you make a calculation of the mass before and after you have created the hole?
If the mass is the same, the hole feature is located outside your model.
If the mass is less, the hole feature is removing material.
If you know it upfront, what will you do if there are more the one solutions? The user is responsible, because he selects the input. Even standard Creo functions will fail if you select a wrong input. You will need some hours, days or even weeks, to determine all valid solutions upfront.
That's what a standard application development is!!! One should notify user about invalid input rather than following what user is providing. We implement the same behavior as long as it is possible even if it is asking for more time.User should be responsible for all valid input to create output, but if user has provided wrong input, It's DUTY of application developer to prompt user rather than creating wrong output.