cquinker
Bioengineer
- Sep 20, 2012
- 16
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
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