' NX 11.0.0.33
' Journal created by MuthuKumar on Thu May 14 10:15:37 2020 Pacific Standard Time
'
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: Format->WCS->Orient...
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
Dim origin1 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim normal1 As NXOpen.Vector3d = New NXOpen.Vector3d(0.0, 0.0, 1.0)
Dim plane1 As NXOpen.Plane = Nothing
plane1 = workPart.Planes.CreatePlane(origin1, normal1, NXOpen.SmartObject.UpdateOption.WithinModeling)
Dim unit1 As NXOpen.Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), NXOpen.Unit)
Dim expression1 As NXOpen.Expression = Nothing
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression2 As NXOpen.Expression = Nothing
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression3 As NXOpen.Expression = Nothing
expression3 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim unit2 As NXOpen.Unit = CType(workPart.UnitCollection.FindObject("Degrees"), NXOpen.Unit)
Dim expression4 As NXOpen.Expression = Nothing
expression4 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit2)
Dim expression5 As NXOpen.Expression = Nothing
expression5 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression6 As NXOpen.Expression = Nothing
expression6 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit2)
Dim expression7 As NXOpen.Expression = Nothing
expression7 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression8 As NXOpen.Expression = Nothing
expression8 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit2)
expression3.RightHandSide = "0"
expression5.RightHandSide = "0"
expression7.RightHandSide = "0"
expression4.RightHandSide = "0"
expression6.RightHandSide = "0"
expression8.RightHandSide = "0"
expression3.RightHandSide = "0"
expression5.RightHandSide = "0"
expression7.RightHandSide = "0"
expression4.RightHandSide = "0"
expression6.RightHandSide = "0"
expression8.RightHandSide = "0"
expression3.RightHandSide = "0"
expression5.RightHandSide = "0"
expression7.RightHandSide = "0"
expression4.RightHandSide = "0"
expression6.RightHandSide = "0"
expression8.RightHandSide = "0"
theSession.SetUndoMarkName(markId1, "CSYS Dialog")
Dim xform1 As NXOpen.Xform = Nothing
xform1 = workPart.Xforms.CreateXformFromCurrentView(NXOpen.SmartObject.UpdateOption.AfterModeling, 1.0)
Dim scaleAboutPoint1 As NXOpen.Point3d = New NXOpen.Point3d(-26.512835686764909, 25.133555217514996, 0.0)
Dim viewCenter1 As NXOpen.Point3d = New NXOpen.Point3d(26.512835686769108, -25.133555217511528, 0.0)
workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint1, viewCenter1)
Dim scaleAboutPoint2 As NXOpen.Point3d = New NXOpen.Point3d(-14.099311463480962, 14.221914171862887, 0.0)
Dim viewCenter2 As NXOpen.Point3d = New NXOpen.Point3d(14.09931146348517, -14.221914171859439, 0.0)
workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint2, viewCenter2)
Dim scaleAboutPoint3 As NXOpen.Point3d = New NXOpen.Point3d(-10.690956170569409, 10.200545337060735, 0.0)
Dim viewCenter3 As NXOpen.Point3d = New NXOpen.Point3d(10.690956170573624, -10.200545337057326, 0.0)
workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint3, viewCenter3)
Dim scaleAboutPoint4 As NXOpen.Point3d = New NXOpen.Point3d(-7.4542446693871902, 8.0035048029249509, 0.0)
Dim viewCenter4 As NXOpen.Point3d = New NXOpen.Point3d(7.4542446693913993, -8.0035048029215456, 0.0)
workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint4, viewCenter4)
Dim brep1 As NXOpen.Features.Brep = CType(workPart.Features.FindObject("UNPARAMETERIZED_FEATURE(0)"), NXOpen.Features.Brep)
Dim edge1 As NXOpen.Edge = CType(brep1.FindObject("EDGE * 6 * 9 {(10,34.0078098595757,30.9496300155993)(10,29.2446701387613,39.1996300155993)(10,24.4815304179469,30.9496300155993) UNPARAMETERIZED_FEATURE(0)}"), NXOpen.Edge)
Dim xform2 As NXOpen.Xform = Nothing
xform2 = workPart.Xforms.CreateXform(edge1, NXOpen.SmartObject.UpdateOption.AfterModeling)
Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "CSYS")
theSession.DeleteUndoMark(markId2, Nothing)
Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "CSYS")
Dim cartesianCoordinateSystem1 As NXOpen.CartesianCoordinateSystem = Nothing
cartesianCoordinateSystem1 = workPart.CoordinateSystems.CreateCoordinateSystem(xform2, NXOpen.SmartObject.UpdateOption.AfterModeling)
xform2.RemoveParameters()
theSession.DeleteUndoMark(markId3, Nothing)
theSession.SetUndoMarkName(markId1, "CSYS")
workPart.Expressions.Delete(expression3)
workPart.Expressions.Delete(expression5)
workPart.Expressions.Delete(expression7)
workPart.Expressions.Delete(expression4)
workPart.Expressions.Delete(expression6)
workPart.Expressions.Delete(expression8)
Try
' Expression is still in use.
workPart.Expressions.Delete(expression2)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try
Try
' Expression is still in use.
workPart.Expressions.Delete(expression1)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try
plane1.DestroyPlane()
Dim nErrs1 As Integer = Nothing
nErrs1 = theSession.UpdateManager.AddToDeleteList(cartesianCoordinateSystem1)
Dim objects1(0) As NXOpen.NXObject
Dim cartesianCoordinateSystem2 As NXOpen.CartesianCoordinateSystem = CType(workPart.FindObject("ENTITY 45 1"), NXOpen.CartesianCoordinateSystem)
objects1(0) = cartesianCoordinateSystem2
Dim nErrs2 As Integer = Nothing
nErrs2 = theSession.UpdateManager.AddToDeleteList(objects1)
Dim origin2 As NXOpen.Point3d = New NXOpen.Point3d(10.0, 29.2446701387613, 33.699630015599304)
Dim matrix1 As NXOpen.Matrix3x3 = Nothing
matrix1.Xx = 6.4594794160009188e-016
matrix1.Xy = 0.0
matrix1.Xz = 1.0
matrix1.Yx = 0.0
matrix1.Yy = 1.0
matrix1.Yz = -0.0
matrix1.Zx = -1.0
matrix1.Zy = 0.0
matrix1.Zz = 6.4594794160009188e-016
workPart.WCS.SetOriginAndMatrix(origin2, matrix1)
Dim id1 As NXOpen.Session.UndoMarkId = Nothing
id1 = theSession.NewestVisibleUndoMark
Dim nErrs3 As Integer = Nothing
nErrs3 = theSession.UpdateManager.DoUpdate(id1)
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module