×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Journal to Create Knurl on Cylindrical Face

Journal to Create Knurl on Cylindrical Face

Journal to Create Knurl on Cylindrical Face

(OP)
I'm trying to write a Journal that would create a Knurl on any cylindrical face, like shown below, with just a few inputs. Manually I create a plane tangent to the face, sketch a curve, wrap it to face, create another sketch, sweep that sketch with the wrapped curve, mirror sweep and then a circular pattern.

I'm new to Journaling and the code below just creates the first plane tangent to the face. It works when my geometry is relative to absolute but I want it to work relative to WCS. Is there any command to make that happen? I've seen Csys.MapPoint in this forum but seems like I should be able to always work off the WCS.



Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Const undoMarkName As String = "NXJ journal"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

Dim myFace As Face
If SelectEdge("select circular edge", myFace) = Selection.Response.Cancel Then
Return
End If

Dim ufs As NXOpen.UF.UFSession = NXOpen.UF.UFSession.GetUFSession
Dim axisPoint(2) As Double
Dim axisVector(2) As Double
Dim box(5) As Double 'minX, minY, minZ, maxX, maxY, maxZ.
Dim surfType As Integer
Dim r1, r2 As Double
Dim flip As Integer
ufs.Modl.AskFaceData(myFace.Tag, surfType, axisPoint, axisVector, box, r1, r2, flip)


Dim origin As New NXOpen.Point3d(box(3),0,box(5)/2)
Dim axisX As New NXOpen.Point3d(box(3),0,box(5)/2-1)
Dim wcsMatrix As NXOpen.Matrix3x3 = workPart.WCS.CoordinateSystem.Orientation.Element
Dim sketchPlane As NXOpen.DatumPlane = workPart.Datums.CreateFixedDatumPlane(origin, wcsMatrix)
Dim horizAxis As NXOpen.DatumAxis = workPart.Datums.CreateFixedDatumAxis(origin, axisX)


End Sub

Function SelectEdge(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "Select circular edge"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_CYLINDRICAL_FACE
End With

Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj, cursor)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

End Module









RE: Journal to Create Knurl on Cylindrical Face

(OP)
I'm trying to use the Mappoint function below but I'm getting a System.NullReferenceException error. Below is a small section of the code. What's my newbie problem?

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim s As Session = Nothing
Dim ufs As UFSession = Nothing

Sub Main()


Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Const undoMarkName As String = "NXJ journal"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

Dim origin As New NXOpen.Point3d(1,2,3)
dim WCSorigin As NXOpen.Point3d
WCSorigin = Abs2WCS(origin)

End Sub


Function Abs2WCS(ByVal inPt As Point3d) As Point3d
Dim pt1(2), pt2(2) As Double

pt1(0) = inPt.X
pt1(1) = inPt.Y
pt1(2) = inPt.Z

ufs.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_COORDS, pt1,UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt2)

Abs2WCS.X = pt2(0)
Abs2WCS.Y = pt2(1)
Abs2WCS.Z = pt2(2)

End Function

End Module

RE: Journal to Create Knurl on Cylindrical Face

Change this:

CODE

Module Module1

Dim s As Session = Nothing
Dim ufs As UFSession = Nothing

Sub Main()


Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession() 

to this:

CODE

Module Module1

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()

Sub Main() 

Then change any code that references the "s" variable to reference the "theSession" variable and likewise update references from "ufs" to "theUfSession" (or keep the "s" and "ufs" variable names if you prefer and change "theSession" and "theUfSession" as required).

As your code stands now, the Abs2Wcs function tries to use the "ufs" variable and fails because this variable has been declared as "nothing" (hence the "null reference" error); it needs to reference the current UF session object.

www.nxjournaling.com

RE: Journal to Create Knurl on Cylindrical Face

I can't help you with that journal, but i can maybe propose a simpler method than the wrap curve.
Use a helix instead, then you do not need the sketch / datumplane/ wrap.


Regards,
Tomas

RE: Journal to Create Knurl on Cylindrical Face

(OP)
Thanks Cowski!

Toost

Helix does sound like a better approach... I was also trying to use the thread feature but was unsuccessful.

(Edit)

Helix approach cuts down the feature tree list quite a bit. Not sure if it represents real geometry of a knurling operation but I usually add a note stating geometry shown is for appearance only and call out a specific Knurl.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Research Report - How Engineers are Using Remote Access
Remote access enables engineers to work from anywhere provided they have an internet connection. We surveyed our audience of engineers, designers and product managers to learn how they use remote access within their organizations. We wanted to know which industries have adopted remote access, which software they are using, and what features matter most. Download Now
eBook - Managing the Context of Product Complexity Using the Digital Twin
Keeping track of changes to complex products is difficult—think Aerospace & Defense equipment, new generations of commercial aircraft, and software-based automobiles. A new way to managing the digital context of the physical product is required and the answer is the Digital Twin. This ebook explores the opportunity available for Operations and Maintenance for the Digital Twin. Download Now
White Paper - Trends in Industrial Filtration
Substantial progress has been made in filtration technologies in recent years. New filter media materials, designs and processes have led to filters that are more efficient, reliable, compact and longer lasting. This white paper will discuss the various trends that are impacting operational responsibilities of MROs today and the resources that are available for staying up-to-date on the latest filtration solutions. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close