Quantcast
Channel: NX Journaling - Journaling / NXOpen API
Viewing all articles
Browse latest Browse all 783

Create points on the faces and get coordinates and normal

$
0
0

Hello

I'm trying create a few points on my body and i wanna get x,y,z and the normal of the face on that point i,j,k. I followed this code NX Journaling but now i have 1 problem, when i click on a face, this create a point behind the face and not on the face, can you see what is wrong with this code? And how can i get the i,j,k of that point?

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF 
Module Module1
 
    Dim theSession As Session = Session.GetSession()Dim theUfSession As UFSession = UFSession.GetUFSession() 
    Sub Main() 
        Dim workPart As Part = theSession.Parts.WorkDim lw As ListingWindow = theSession.ListingWindow
        lw.Open() 
        Const undoMarkName AsString="create endpoint"Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName) 
        Dim selectedFace As Face
        Dim selectedPoint As Point3d
        Dim count AsInteger 
        for count =0to15 
            If SelectAnFace("Select an Face", selectedFace, selectedPoint)= Selection.Response.CancelThenexitforEndIf 
            Dim scalar1 As Scalar
            scalar1 = workPart.Scalars.CreateScalar(1, Scalar.DimensionalityType.None, SmartObject.UpdateOption.WithinModeling) 
            'create pointDim Point_Face As Point
            Point_Face = workPart.Points.CreatePoint(selectedPoint)
            Point_Face.SetVisibility(SmartObject.VisibilityOption.Visible) 
            lw.WriteLine("")
            lw.WriteLine("x= "& selectedPoint.x)
            lw.WriteLine("y= "& selectedPoint.y)
            lw.WriteLine("z= "& selectedPoint.z)
            lw.WriteLine("i= ")
            lw.WriteLine("j= ")
            lw.WriteLine("k= ") 
        Next 
        lw.Close() 
    EndSub 
    Function SelectAnFace(prompt AsString, ByRef selFace As Face, ByRef selPos As Point3d)As Selection.Response 
        Dim selObj As NXObject
        Dim theUI As UI = UI.GetUIDim cursor As Point3d
        Dim typeArray()As Selection.SelectionType={Selection.SelectionType.Faces} 
        Dim resp As Selection.Response= theUI.SelectionManager.SelectObject( prompt, "Select a Point in a Face", _
                Selection.SelectionScope.AnyInAssembly, False, typeArray, selObj, cursor) 
        If resp = Selection.Response.ObjectSelectedOr resp = Selection.Response.ObjectSelectedByNameThen
            selFace = selObj
            selPos = cursor
            Return Selection.Response.OkElseReturn Selection.Response.CancelEndIf 
    EndFunction 
    PublicFunction GetUnloadOption(ByVal dummy AsString)AsInteger
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.ImmediatelyEndFunction 
EndModule

Viewing all articles
Browse latest Browse all 783

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>