Reply
Solved! Go to solution

GetNormal vector on round face

[ Edited ]

Hi all,

 

I'm trying to get the normal vector of face and everything works well with planar face but I can't manage to get correct vector for the middle of a round surface (U=0.5 and V=0.5).

 

I'm using what I find in the SDK as an example :

Private Sub Form_Load()
    Dim objApp As solidedgeframework.Application
    Dim objDoc As SolidEdgepart.PartDocument
    Dim objBody As solidedgegeometry.Body
    Dim objFace As solidedgegeometry.Face
    Dim dblParam(3) As Double
    Dim dblNormal() As Double
    Const TESTFILE = "T:\vbtests\testcases\HalfCyl.par"
    ' Report errors
    Const PI = 3.14159265358979
    ' Create/get the application with specific settings
    On Error Resume Next
    Set objApp = GetObject(, "SolidEdge.Application")
    If Err Then
        Err.Clear
        Set objApp = CreateObject("SolidEdge.Application")
        Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")
        objApp.Visible = True
    Else
        Set objDoc = objApp.ActiveDocument
    End If
    Call objDoc.Close
    ' opening the testfile
    Set objDoc = objApp.Documents.Open(TESTFILE)
    ' getting the body object of the model
    Set objBody = objDoc.Models(1).Body
    ' getting a particular face from the collection of faces on the body
    Set objFace = objBody.Faces(FaceType:=igQueryAll).Item(2)
    ' getting the normal at a point (u=0.5, v=0.5) on a Face
    dblParam(0) = 3 * PI / 2
    dblParam(1) = 0.1
    dblParam(2) = PI / 2
    dblParam(3) = 0.05
    Call objFace.GetNormal(NumParams:=2, Params:=dblParam, Normals:=dblNormal)
    ' USER DISPLAY
    ' Release objects
    Set objApp = Nothing
    Set objDoc = Nothing
    Set objBody = Nothing
    Set objFace = Nothing
End Sub

Can you tell me how are calculate dblParam values and if the value I'm using (same as in the exaple) are corrects.

 

Thanks.

 

Romuald


Romuald BERTIN
2 REPLIES
Solution
Solution
Accepted by topic author rbertin
‎02-11-2016 09:43 AM

Re: GetNormal vector on round face

Hi rbertin,

 

For planar faces, the midpoint has the (parametric) coordinates uv(0.5, 0.5) since the parametric range goes from 0.0 to 1.0. This is different for cylindrical faces. Prior to calculate the normal for the midpoint, you should always retrieve the parametric range of that face, and then use the parametric extents to calculate the coordinates of the midpoint.

 

Refer to this sample function for details:

 

    Private Sub GetNormal(ByVal seFace As SolidEdgeGeometry.Face)
        Console.WriteLine("Face {0}: ", seFace.ID)

        Dim minParam As Double() = {}
        Dim maxParam As Double() = {}

        seFace.GetParamRange(minParam, maxParam)
        Console.WriteLine("    ParamRange MinParam uv({0} {1}) MaxParam uv({2} {3})",
            minParam(0), minParam(1), maxParam(0), maxParam(1))

        Dim midParam As Double() = {
            ((maxParam(0) - minParam(0)) * 0.5) + minParam(0),
            ((maxParam(1) - minParam(1)) * 0.5) + minParam(1)
        }
        Console.WriteLine("    MidParam uv({0} {1})", midParam(0), midParam(1))

        Dim midNormal As Double() = {}
        seFace.GetNormal(1, midParam, midNormal)
        Console.WriteLine("    MidNormal xyz({0} {1} {2})", midNormal(0), midNormal(1), midNormal(2))

        Dim midPoint As Double() = {}
        seFace.GetPointAtParam(1, midParam, midPoint)
        Console.WriteLine("    MidPoint xyz({0} {1} {2})", midPoint(0), midPoint(1), midPoint(2))
    End Sub

Hope this helps,

Herbert

 

Re: GetNormal vector on round face

Thanks for this answer Herbert, works like a charm. Robot Happy

 

Romuald

 


Romuald BERTIN