Help with GetNormalAtPoint in C# needed (VB.Net - OK)

Help with GetNormalAtPoint in C# needed (VB.Net - OK)

Maxim-CADman77
Advisor Advisor
318 Views
2 Replies
Message 1 of 3

Help with GetNormalAtPoint in C# needed (VB.Net - OK)

Maxim-CADman77
Advisor
Advisor

I'm trying to convert my VB.Net project to C# (some employers prefer C#) and I feel a bit confused with usage of GetNormalAtPoint method (on the same dataset it fails to return same result as VB.Net does).

VB.Net code (piece of interest):

 

Call oFrF.Evaluator.GetNormalAtPoint(pt, n)

MessageBox.Show("oFrF.TransientKey = " & oFrF.TransientKey & vbCrLf & "pt : " & pt(0) & "  ;  " & pt(1) & "  ;  " & pt(2) & vbCrLf & "n : " & n(0) & "  ;  " & n(1) & "  ;  " & n(2), "VB")

 

C#:

 

oFrF.Evaluator.GetNormalAtPoint(pt, n);

MessageBox.Show ("oFrF.TransientKey = " + oFrF.TransientKey + System.Environment.NewLine + "pt : " + pt[0] + "  ;  " + pt[1] + "  ;  " + pt[2] + System.Environment.NewLine + "n : " + n[0] + "  ;  " + n[1] + "  ;  " + n[2],"C#");

 

I'm expecting to get the same coordinates of n (Point) on same "oFrF" (Face) and "pt" (Point) but I get zero:

C#-GetNormalAtPoint-Issue (vs VB).jpg

What I'm missing?

 

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Accepted solutions (1)
319 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor
Accepted solution

You miss the 'ref' keyword in method calls

var part = ThisDoc.Document as PartDocument;
var face = part.ComponentDefinition.SurfaceBodies[1].Faces[1];

var pointOnFace = face.PointOnFace;
double[] point = { };
pointOnFace.GetPointData(ref point);

double[] normal = {};
face.Evaluator.GetNormalAtPoint(ref point,  ref normal);

MessageBox.Show(string.Join(";", normal));

 

0 Likes
Message 3 of 3

Maxim-CADman77
Advisor
Advisor

Yes, correct C#-code is:

 

oFrF.Evaluator.GetNormalAtPoint(ref pt, ref n)

 

... seems a bit strange that Visual Studio* IntelliCode does not detect an issue if no keyword is used ... while it gives correct hint if the wrong keyword (ex. 'out') is used:

Screenshot 2022-06-16 183407.jpg

Thank you so much!

 

* I'm using VS Community 2019 version 16.11.16

Please vote for Inventor-Idea Text Search within Option Names

0 Likes