How to get "circle direction" of EdgeProxy?

How to get "circle direction" of EdgeProxy?

bindlmi
Advocate Advocate
282 Views
9 Replies
Message 1 of 10

How to get "circle direction" of EdgeProxy?

bindlmi
Advocate
Advocate

Hi,
I am currently failing to determine the direction in which a circle "is facing". The constraint-command shows me these directions, and I would like to read out these values via API.

bindlmi_0-1747202697937.png

Any suggestions? Unfortunately it is not .Geometry.Normal

0 Likes
Accepted solutions (1)
283 Views
9 Replies
Replies (9)
Message 2 of 10

cidhelp
Advocate
Advocate

Hello @bindlmi ,

 

I would look for the faces-collection of the selected circular edge. If there is a face with surfacetype = kplanesurface then you can use this face's Geometry.Normal.

If there is no plane surface, you only can get the circulrar edge's Geometry.Normal.

It seams, that this is the logic of the insert-constraint, but I'm not sure.

0 Likes
Message 3 of 10

bindlmi
Advocate
Advocate

Thx for your suggestion, I've been thinking about that too. However, these values don't make any sense at all.

bindlmi_1-1747214695039.png

Strangely enough, surfaces 1 and 2 have the same normal vector, although surface 2 is clearly pointing downwards. And surface 3 actually points upwards. I also discovered the IsParamReversed-Value as a difference, but I don't know what it means

 

0 Likes
Message 4 of 10

WCrihfield
Mentor
Mentor
Accepted solution

I suggest that instead of using Face.Geometry.Normal, you use Face.Evaluator.GetNormal or Face.Evaluator.GetNormalAtPoint methods, then use those Normals coordinates to create the Vector or UnitVector.  The Face itself, and the underlying Transient Geometry object that represents its shape, can be different orientations/normals.  The Face object is more stable, and its 'Normal' will pretty much always be pointing away from the material (from within the material to outside the material).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 10

bindlmi
Advocate
Advocate

Hi,
thanks, that seems to work. I don't understand the param(), but as long as it runs... (I found this via an example from the Inventor API Help).
It doesn't work for the conical surface, but I'll find another connection there (probably the cylinder axis)

bindlmi_0-1747310973333.png

Thanks for your help!

 

0 Likes
Message 6 of 10

bindlmi
Advocate
Advocate

Hi,
I'm afraid I need more help after all. In C# I only get an empty array back. They are the same areas as on the screenshot before.

If it matters: I run through all Occurrences, and there through all HoleFeatures.

bindlmi_0-1747636032005.png

Why does it work in VBA, but not in C#?

 

0 Likes
Message 7 of 10

bindlmi
Advocate
Advocate

Nevermind, forgot the "ref" in this line:

oFace.Evaluator.GetNormal(param, ref planeNormal);

It works fine 🙂

0 Likes
Message 8 of 10

WCrihfield
Mentor
Mentor

Glad you got it working OK.  I was going to reply to your post in Message 5 (on the 15th) about the 'params', but things got busy at work, and I got called away.  The 'params' portion of the SurfaceEvaluator.GetNormal method seems to be sort of like a percentage grid of the overall face.  That method is usually OK to use when dealing with a relatively simple faces with no holes, voids, cutouts, or interruptions in them.  But when any of those may be involved, it is usually better to use the SurfaceEvaluator.GetNormalAtPoint method.  A common strategy for getting/setting the 'points' portion of that method, which is being used similarly to the 'params' in the other method, is to use the Face.PointOnFace property to get an Inventor.Point object that is guaranteed to be 'on' that Face, rather than in one of those holes, voids, cutouts, or interruptions.  Then use the X, Y, & Z coordinates of that Point as the coordinates of the 'points' array of Double it is asking for.  This will tell it to get the 'normal' at that exact point on that face, ensuring proper results, and avoiding a potential error.  The other 'evaluator' type objects you may encounter somewhere along the way are the CurveEvaluator and the Curve2dEvaluator.  The following online help page touches on these concepts, but does not go into great detail.

Programming Interface > Inventor API User's Manual > Part and Assembly Modeling > Understanding Soli... 

Another small detail that often trips some of us up in these types of situations, is when declaring and initializing the variables that the method(s) will be using.  In vb.net (and in iLogic rules, which use vb.net), it is necessary to declare the 'Normals' variable similar to this:

Dim oNormals() As Double = {}

...instead of just like this:

Dim oNormals() As Double

...even though we are not setting any initial values to it, and want the method to set its values.  This did not seem to be necessary in VBA, and is not that obvious in any of the 'official' documentation that this needs to be done, but when not done, it will usually throw an error.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 10

bindlmi
Advocate
Advocate

I understand your concern that you could run into an error with the random params.
The approach with the PointOnFace seems more logical.

I once tried to force an error, but I didn't succeed. I tested different params and specifically tried to hit a hole, but without “success”. Even very high values could be processed, although my face is not that big.

Here is a comparison showing that both methods produce the same result (at least for my test part). I've selected the top face, the front, the right and the bottom.

bindlmi_0-1747894540632.png 

bindlmi_1-1747894634842.png

 

 

0 Likes
Message 10 of 10

WCrihfield
Mentor
Mentor

We probably won't see much difference (if any) when using both the Face & SurfaceEvaluator (instead of Plane & Plane.Normal), and 100% of the faces we encounter are 'planar', even when there are holes/voids/cutouts in the face, because that is a pretty stable scenario.  I have done some similar testing too using iLogic rules and the iLogic Log window, and had similar results.  I was mainly just passing along stuff I learned from Mike Deck (Inventor API guru) in one or more other forum discussions at some point in the past.  He is a software developer/programmer who has been with Autodesk for decades, and occasionally pops in to help with especially difficult or undocumented scenarios being discussed in this forum since its inception.  Also, you may have already seen this by now, but there is a 'Property' of the SurfaceEvaluator named IsParamOnFace, which is pretty self explanatory, and can be useful in situations like these.  I don't do much of this sort of thing on radial, lofted, or otherwise curved surfaces, so not sure what the implications/importance of it may be in those situations.

Edit:  Attached is one of my iLogic rule base test codes.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes