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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to confirm hole is removing material or not using toolkit

Ketan_Lalcheta
19-Tanzanite

How to confirm hole is removing material or not using toolkit

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

 

24 REPLIES 24

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

Appreciate your patience... Thanks for responding on this issue.

Checking for hole failure is not something one can do. Toolkit Api doesn't return error if hole doesn't remove material. Same type of hole (outside part geometry ) is possible manually also. + We want to restrict hole creation itself if input is not proper. Thus, can't go with failed feature creation.

Coming to your idea of point creation, this seems good. But what api to be used to find coordinate of point which is offset from two surfaces and lying on third surface. I know geom item data may help but can't formulate algorithm w.r.t. api

Hi!

 

UG->"Element Trees Datum Features" gives all the info for feature data trees.

UgGeneralPointCreate.c also provides example for point.

 

Cheers,

csaba

 

 

As I am not having creo with me now, I cannot refer document but will definitely have a look tomorrow morning.

Whatever documents you suggested might be giving idea about what to be filled into element tree for feature creation. In other word, put x , y and z as 50,50, 25. it must not contain what to be done to come up with value of co ordinate x,y and z. This has to be implemented by us with defining proper algorithm and api of surface property. I need help on this to achieve point coordinate which lies on a surface and is offsetted by two other surface at some distance.
FV
17-Peridot
17-Peridot
(To:Ketan_Lalcheta)

Hello all, Ketan, You'll need to start with getting info out of the three ProSelection objects you are getting from a user GUI interaction. Assuming that a user had selected a placement surface in the vicinity of the intended hole feature and the placement surface is not a datum plane... The first selection is the placement surface and you'll need to get a 'pick point' coordinates with ProSelectionPoint3dGet and UV parameters with ProSelecitonUvParamGet. You also need to get ProGeomitem with ProSelectionModelitemGet. The same info needs to be extracted for offset planes. After that you'll need to get normal vectors at 'pick' locations with ProSurfaceXyzdataEval. Now you have three 'computational' planes representing by point-with-normal-vector form. 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. Calculate the vector product of the first offset plane normal vector and the second offset plane normal vecor and translate it by offset distances. This will be the input into ProSolidRayIntersectionCompute. Compare results of the ray selection with the placement surface selection - has to be the same surface. As a side note - the hole UDF has to be created using the default coordinate system with the 'yellow' side of offset datum planes being used, with hole axis being located in the first quadrant of XY plane and being parallel to Z axis of the default coordinate system - otherwise the coordinate transformations from UDF internal frame to the model frame will make your life trully miserable... HIH. FV.
Ketan_Lalcheta
19-Tanzanite
(To:FV)

Thank you so so much for your detailed response.. I will surely give a try what you have mentioned.... Additionally, below is what I have done for hole placement reference as surfaces..

Primary placement reference edges are found out which should be four edges..for each of the edges, I am trying to find neighbour edges and surface using Api edgeneighbourget. Consider only two edges as required edges for which neighbour surface found by api from edge is same as user selected secondary surfaces. Now, we have two edges and find common point of edges by start and end point of both the edges. Additionally, from edge start and end point, find slope I.e. unit vector by doing (start point x-end point x )/magnitude. Same way , y and z component as well as other edge's vector is calculated.. this might be useful for direction.
Next step is to fully test first logic, then prepare logic for hole placement with datum planes and radial hole placement on planner as well as cylindrical surface.

Any thoughts will help a lot.
Ketan_Lalcheta
19-Tanzanite
(To:FV)

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.

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

Ketan, It would be a good idea to post a snippet of your code showing the problem with unit vector calculation. It is quite difficult to help you to pinpoint the issue without seeing what you were doing... FV.
Ketan_Lalcheta
19-Tanzanite
(To:FV)

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.

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

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.

Guys, thank you for your response,,, I need to know (before hole creation it self) whether hole is going to remove material or not.

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. 

 

Ketan_Lalcheta
19-Tanzanite
(To:RPN)

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.

Announcements


Top Tags