×
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

Jobs

NX Journaling problem with Datum Axis

NX Journaling problem with Datum Axis

NX Journaling problem with Datum Axis

(OP)
So, in UG/NX 7.5, I'm writing a journal that entails a combination of point, datum axis, and datum plane creation. I currently have the issue that once I create a datum axis, I cannot store the object in a variable... I only have the variable of the type Features.DatumAxisBuilder or an NXObject containing the Commit() of the DatumAxisBuilder. How do I actually get the object of type DatumAxis when I'm creating the datum axis.

Here's my sample code from creating the datum axis:

Option Strict Off
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports NXOpen

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()

Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim pointList As PointCollection = workPart.Points
Dim featureList As Features.FeatureCollection = workPart.Features
Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
Dim nullFeatures_Feature As Features.Feature = Nothing

If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw(New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))
End If
Dim datumAxis_Perp As Features.DatumAxisBuilder
datumAxis_Perp = workPart.Features.CreateDatumAxisBuilder(nullFeatures_Feature)
datumAxis_Perp.IsAssociative = True
Dim added1 As Boolean
added1 = datumAxis_Perp.Objects.Add(psymph_pt)
'APP_datumPlane
Dim added2 As Boolean
added2 = datumAxis_Perp.Objects.Add(APP_datumPlane)
Dim direction9 As Direction
direction9 = workPart.Directions.CreateDirection(APP_datumPlane, Sense.Forward, SmartObject.UpdateOption.WithinModeling)
datumAxis_Perp.Vector = direction9
datumAxis_Perp.IsAxisReversed = True
datumAxis_Perp.ResizedEndDistance = 36.6453605251759
Dim nXObject2 As NXObject
nXObject2 = datumAxis_Perp.Commit()
nXObject2.SetName("APP_Orthogonal_Axis")



The issue is that when I want to reference the datum axis created here (with the hope of creating another datum axis that is parallel to this axis and beginning at a different point), I cannot reference the object. The code is as follows:

If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw(New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))
End If
Dim datumAxis_Center As Features.DatumAxisBuilder
datumAxis_Center = workPart.Features.CreateDatumAxisBuilder(nullFeatures_Feature)
datumAxis_Center.IsAssociative = True
Dim addedCenter1 As Boolean
addedCenter1 = datumAxis_Center.Objects.Add(rt_center_pt)
'APP_datumPlane
Dim addedCenter2 As Boolean
addedCenter2 = datumAxis_Center.Objects.Add(DATUMAXISOBJECT)
Dim directionCenter As Direction
directionCenter = workPart.Directions.CreateDirection(DATUMAXISOBJECT.GetEntities(0), Sense.Forward, SmartObject.UpdateOption.WithinModeling)
datumAxis_Center.Vector = directionCenter
datumAxis_Center.IsAxisReversed = True
datumAxis_Center.ResizedEndDistance = 36.6453605251759
Dim nXObjectCenter As NXObject
nXObjectCenter = datumAxis_Center.Commit()
nXObjectCenter.SetName("Center_Orthogonal_Axis")




Locations with "DATUMAXISOBJECT" signify where I need this DatumAxis type object.
Please ignore any other fallacies in the code samples that are irrelevant to the issue at hand (these are taken from a larger program).

Any help will be appreciated,
Chris

RE: NX Journaling problem with Datum Axis

The Commit method of the DatumAxisBuilder will return a datum axis feature. Instead of:

CODE

Dim nXObject2 As NXObject
nXObject2 = datumAxis_Perp.Commit() 

try:

CODE

Dim nXObject2 As Features.DatumAxisFeature
nXObject2 = datumAxis_Perp.Commit() 

nXObject2 will be a reference to the datum axis feature. To get the datum axis itself use:

CODE

nXObject2.DatumAxis 

www.nxjournaling.com

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!


Resources