pittbuck
Computer
- May 1, 2017
- 31
Hello. I'm trying to move a solid from layer 180 to 195, but flip it such that when I click CTRL-ALT-HOME, I can see the bottom of the solid. Presently, I am doing "Move Object" and I am using "CSYS to CSYS" as the motion. The "from CSYS" is a Datum CSYS on layer 42. The "to CSYS" is the absolute coordinate system. And, as obvious as it may sound, I also it set such that the result is a copied original specified to Layer 195.
Using the "record journal" tool, I get the following:
I've done a little bit of journaling before, so I did manage to get the basic stuff changed. The issue just becomes where to go after this (note, this will be added on to another journal I have at a later date):
The first highlighted portion is where I get a little lost in what the input needs to be. I'm assuming that I need to assign the CSYS on layer 42 at some point before this (maybe?). The second highlighted point, I'm assuming is where the "bodiesOnFlipLayer" would go. A little bit of guidance on how to clean this up would be much appreciated. Thank you.
Using the "record journal" tool, I get the following:
Code:
Option Strict Off
Imports System
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
' ----------------------------------------------
' Menu: Edit->Move Object...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
Dim nullFeatures_MoveObject As Features.MoveObject = 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 moveObjectBuilder1 As Features.MoveObjectBuilder
moveObjectBuilder1 = workPart.BaseFeatures.CreateMoveObjectBuilder(nullFeatures_MoveObject)
Dim unit1 As Unit
unit1 = moveObjectBuilder1.TransformMotion.RadialOriginDistance.Units
Dim expression1 As Expression
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression2 As Expression
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression3 As Expression
expression3 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression4 As Expression
expression4 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression5 As Expression
expression5 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression6 As Expression
expression6 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression7 As Expression
expression7 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression8 As Expression
expression8 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression9 As Expression
expression9 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression10 As Expression
expression10 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression11 As Expression
expression11 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression12 As Expression
expression12 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression13 As Expression
expression13 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression14 As Expression
expression14 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression15 As Expression
expression15 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression16 As Expression
expression16 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression17 As Expression
expression17 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression18 As Expression
expression18 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression19 As Expression
expression19 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression20 As Expression
expression20 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression21 As Expression
expression21 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression22 As Expression
expression22 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression23 As Expression
expression23 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression24 As Expression
expression24 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression25 As Expression
expression25 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression26 As Expression
expression26 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression27 As Expression
expression27 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression28 As Expression
expression28 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
moveObjectBuilder1.TransformMotion.DistanceAngle.OrientXpress.AxisOption = GeometricUtilities.OrientXpressBuilder.Axis.Passive
moveObjectBuilder1.TransformMotion.DistanceAngle.OrientXpress.PlaneOption = GeometricUtilities.OrientXpressBuilder.Plane.Passive
moveObjectBuilder1.TransformMotion.OrientXpress.AxisOption = GeometricUtilities.OrientXpressBuilder.Axis.Passive
moveObjectBuilder1.TransformMotion.OrientXpress.PlaneOption = GeometricUtilities.OrientXpressBuilder.Plane.Passive
Dim manipulatororigin1 As Point3d
manipulatororigin1 = moveObjectBuilder1.TransformMotion.ManipulatorOrigin
Dim manipulatormatrix1 As Matrix3x3
manipulatormatrix1 = moveObjectBuilder1.TransformMotion.ManipulatorMatrix
moveObjectBuilder1.TransformMotion.Option = GeometricUtilities.ModlMotion.Options.CsysToCsys
moveObjectBuilder1.MoveObjectResult = Features.MoveObjectBuilder.MoveObjectResultOptions.CopyOriginal
moveObjectBuilder1.LayerOption = Features.MoveObjectBuilder.LayerOptionType.AsSpecified
moveObjectBuilder1.Layer = 195
moveObjectBuilder1.TransformMotion.DistanceValue.RightHandSide = "0.8"
moveObjectBuilder1.TransformMotion.Angle.RightHandSide = "0.5"
theSession.SetUndoMarkName(markId1, "Move Object Dialog")
Dim origin1 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim vector1 As Vector3d = New Vector3d(-0.316576442411312, -0.693544753222139, -0.647128295926117)
Dim direction1 As Direction
direction1 = workPart.Directions.CreateDirection(origin1, vector1, SmartObject.UpdateOption.WithinModeling)
Dim nullPoint As Point = Nothing
Dim axis1 As Axis
axis1 = workPart.Axes.CreateAxis(nullPoint, direction1, SmartObject.UpdateOption.WithinModeling)
moveObjectBuilder1.TransformMotion.AngularAxis = axis1
moveObjectBuilder1.TransformMotion.AngularAxis = axis1
Dim origin2 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim vector2 As Vector3d = New Vector3d(-0.0, -0.0, -1.0)
Dim direction2 As Direction
direction2 = workPart.Directions.CreateDirection(origin2, vector2, SmartObject.UpdateOption.WithinModeling)
moveObjectBuilder1.TransformMotion.ToVector = direction2
Dim body1 As Body = CType(workPart.Bodies.FindObject("UNPARAMETERIZED_FEATURE(117)"), Body)
Dim added1 As Boolean
added1 = moveObjectBuilder1.ObjectToMoveObject.Add(body1)
Dim cartesianCoordinateSystem1 As CartesianCoordinateSystem = CType(workPart.FindObject("ENTITY 45 1 1"), CartesianCoordinateSystem)
Dim xform1 As Xform
xform1 = workPart.Xforms.CreateXform(cartesianCoordinateSystem1, SmartObject.UpdateOption.WithinModeling)
Dim cartesianCoordinateSystem2 As CartesianCoordinateSystem
cartesianCoordinateSystem2 = workPart.CoordinateSystems.CreateCoordinateSystem(xform1, SmartObject.UpdateOption.WithinModeling)
moveObjectBuilder1.TransformMotion.FromCsys = cartesianCoordinateSystem2
Dim xform2 As Xform
xform2 = workPart.Xforms.CreateXform(SmartObject.UpdateOption.WithinModeling, 1.0)
Dim cartesianCoordinateSystem3 As CartesianCoordinateSystem
cartesianCoordinateSystem3 = workPart.CoordinateSystems.CreateCoordinateSystem(xform2, SmartObject.UpdateOption.WithinModeling)
moveObjectBuilder1.TransformMotion.ToCsys = cartesianCoordinateSystem3
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Move Object")
Dim nXObject1 As NXObject
nXObject1 = moveObjectBuilder1.Commit()
Dim objects1() As NXObject
objects1 = moveObjectBuilder1.GetCommittedObjects()
theSession.DeleteUndoMark(markId2, Nothing)
theSession.SetUndoMarkName(markId1, "Move Object")
moveObjectBuilder1.Destroy()
workPart.Expressions.Delete(expression3)
workPart.Expressions.Delete(expression4)
workPart.Expressions.Delete(expression10)
workPart.Expressions.Delete(expression11)
workPart.Expressions.Delete(expression12)
workPart.Expressions.Delete(expression19)
workPart.Expressions.Delete(expression20)
workPart.Expressions.Delete(expression1)
workPart.Expressions.Delete(expression2)
workPart.Expressions.Delete(expression5)
workPart.Expressions.Delete(expression6)
workPart.Expressions.Delete(expression9)
workPart.Expressions.Delete(expression15)
workPart.Expressions.Delete(expression18)
workPart.Expressions.Delete(expression23)
workPart.Expressions.Delete(expression24)
workPart.Expressions.Delete(expression25)
workPart.Expressions.Delete(expression7)
workPart.Expressions.Delete(expression8)
workPart.Expressions.Delete(expression13)
workPart.Expressions.Delete(expression14)
workPart.Expressions.Delete(expression16)
workPart.Expressions.Delete(expression17)
workPart.Expressions.Delete(expression21)
workPart.Expressions.Delete(expression22)
workPart.Expressions.Delete(expression28)
workPart.Expressions.Delete(expression26)
workPart.Expressions.Delete(expression27)
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
I've done a little bit of journaling before, so I did manage to get the basic stuff changed. The issue just becomes where to go after this (note, this will be added on to another journal I have at a later date):
Code:
Option Strict Off
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.UF
Module NXJournal
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim theUFSession As UFSession = UFSession.GetUFSession
'get list of solid bodies on given layer
Dim layerFlip As Integer = 180
Dim bodiesOnFlipLayer As New List(Of Body)
For Each temp As Body In workPart.Bodies
If temp.IsSolidBody Then
If temp.Layer = layerFlip Then
End If
End If
Next
' ----------------------------------------------
' Menu: Edit->Move Object...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Move solids on layer " & layerFlip.ToString)
Dim nullFeatures_MoveObject As Features.MoveObject = Nothing
Dim moveObjectBuilder1 As Features.MoveObjectBuilder
moveObjectBuilder1 = workPart.BaseFeatures.CreateMoveObjectBuilder(nullFeatures_MoveObject)
Dim unit1 As Unit
unit1 = moveObjectBuilder1.TransformMotion.RadialOriginDistance.Units
Dim expression1 As Expression
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression2 As Expression
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression3 As Expression
expression3 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression4 As Expression
expression4 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression5 As Expression
expression5 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression6 As Expression
expression6 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression7 As Expression
expression7 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression8 As Expression
expression8 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression9 As Expression
expression9 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression10 As Expression
expression10 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression11 As Expression
expression11 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression12 As Expression
expression12 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression13 As Expression
expression13 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression14 As Expression
expression14 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression15 As Expression
expression15 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression16 As Expression
expression16 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression17 As Expression
expression17 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression18 As Expression
expression18 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression19 As Expression
expression19 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression20 As Expression
expression20 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression21 As Expression
expression21 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression22 As Expression
expression22 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression23 As Expression
expression23 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression24 As Expression
expression24 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression25 As Expression
expression25 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression26 As Expression
expression26 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression27 As Expression
expression27 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression28 As Expression
expression28 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
moveObjectBuilder1.TransformMotion.DistanceAngle.OrientXpress.AxisOption = GeometricUtilities.OrientXpressBuilder.Axis.Passive
moveObjectBuilder1.TransformMotion.DistanceAngle.OrientXpress.PlaneOption = GeometricUtilities.OrientXpressBuilder.Plane.Passive
moveObjectBuilder1.TransformMotion.OrientXpress.AxisOption = GeometricUtilities.OrientXpressBuilder.Axis.Passive
moveObjectBuilder1.TransformMotion.OrientXpress.PlaneOption = GeometricUtilities.OrientXpressBuilder.Plane.Passive
Dim manipulatororigin1 As Point3d
manipulatororigin1 = moveObjectBuilder1.TransformMotion.ManipulatorOrigin
Dim manipulatormatrix1 As Matrix3x3
manipulatormatrix1 = moveObjectBuilder1.TransformMotion.ManipulatorMatrix
moveObjectBuilder1.TransformMotion.Option = GeometricUtilities.ModlMotion.Options.CsysToCsys
moveObjectBuilder1.MoveObjectResult = Features.MoveObjectBuilder.MoveObjectResultOptions.CopyOriginal
moveObjectBuilder1.LayerOption = Features.MoveObjectBuilder.LayerOptionType.AsSpecified
moveObjectBuilder1.Layer = 195
moveObjectBuilder1.TransformMotion.DistanceValue.RightHandSide = "0.8"
moveObjectBuilder1.TransformMotion.Angle.RightHandSide = "0.5"
[highlight #FCAF3E]theSession.SetUndoMarkName(markId1, "Move Object Dialog")[/highlight]
Dim origin1 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim vector1 As Vector3d = New Vector3d(-0.316576442411312, -0.693544753222139, -0.647128295926117)
Dim direction1 As Direction
direction1 = workPart.Directions.CreateDirection(origin1, vector1, SmartObject.UpdateOption.WithinModeling)
Dim nullPoint As Point = Nothing
Dim axis1 As Axis
axis1 = workPart.Axes.CreateAxis(nullPoint, direction1, SmartObject.UpdateOption.WithinModeling)
moveObjectBuilder1.TransformMotion.AngularAxis = axis1
moveObjectBuilder1.TransformMotion.AngularAxis = axis1
Dim origin2 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim vector2 As Vector3d = New Vector3d(-0.0, -0.0, -1.0)
Dim direction2 As Direction
direction2 = workPart.Directions.CreateDirection(origin2, vector2, SmartObject.UpdateOption.WithinModeling)
moveObjectBuilder1.TransformMotion.ToVector = direction2
[highlight #FCE94F]Dim body1 As Body = CType(workPart.Bodies.FindObject("UNPARAMETERIZED_FEATURE(117)"), Body)[/highlight]
Dim added1 As Boolean
added1 = moveObjectBuilder1.ObjectToMoveObject.Add(body1)
Dim cartesianCoordinateSystem1 As CartesianCoordinateSystem = CType(workPart.FindObject("ENTITY 45 1 1"), CartesianCoordinateSystem)
Dim xform1 As Xform
xform1 = workPart.Xforms.CreateXform(cartesianCoordinateSystem1, SmartObject.UpdateOption.WithinModeling)
Dim cartesianCoordinateSystem2 As CartesianCoordinateSystem
cartesianCoordinateSystem2 = workPart.CoordinateSystems.CreateCoordinateSystem(xform1, SmartObject.UpdateOption.WithinModeling)
moveObjectBuilder1.TransformMotion.FromCsys = cartesianCoordinateSystem2
Dim xform2 As Xform
xform2 = workPart.Xforms.CreateXform(SmartObject.UpdateOption.WithinModeling, 1.0)
Dim cartesianCoordinateSystem3 As CartesianCoordinateSystem
cartesianCoordinateSystem3 = workPart.CoordinateSystems.CreateCoordinateSystem(xform2, SmartObject.UpdateOption.WithinModeling)
moveObjectBuilder1.TransformMotion.ToCsys = cartesianCoordinateSystem3
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Move Object")
Dim nXObject1 As NXObject
nXObject1 = moveObjectBuilder1.Commit()
Dim objects1() As NXObject
objects1 = moveObjectBuilder1.GetCommittedObjects()
theSession.DeleteUndoMark(markId2, Nothing)
theSession.SetUndoMarkName(markId1, "Move Object")
moveObjectBuilder1.Destroy()
workPart.Expressions.Delete(expression3)
workPart.Expressions.Delete(expression4)
workPart.Expressions.Delete(expression10)
workPart.Expressions.Delete(expression11)
workPart.Expressions.Delete(expression12)
workPart.Expressions.Delete(expression19)
workPart.Expressions.Delete(expression20)
workPart.Expressions.Delete(expression1)
workPart.Expressions.Delete(expression2)
workPart.Expressions.Delete(expression5)
workPart.Expressions.Delete(expression6)
workPart.Expressions.Delete(expression9)
workPart.Expressions.Delete(expression15)
workPart.Expressions.Delete(expression18)
workPart.Expressions.Delete(expression23)
workPart.Expressions.Delete(expression24)
workPart.Expressions.Delete(expression25)
workPart.Expressions.Delete(expression7)
workPart.Expressions.Delete(expression8)
workPart.Expressions.Delete(expression13)
workPart.Expressions.Delete(expression14)
workPart.Expressions.Delete(expression16)
workPart.Expressions.Delete(expression17)
workPart.Expressions.Delete(expression21)
workPart.Expressions.Delete(expression22)
workPart.Expressions.Delete(expression28)
workPart.Expressions.Delete(expression26)
workPart.Expressions.Delete(expression27)
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
The first highlighted portion is where I get a little lost in what the input needs to be. I'm assuming that I need to assign the CSYS on layer 42 at some point before this (maybe?). The second highlighted point, I'm assuming is where the "bodiesOnFlipLayer" would go. A little bit of guidance on how to clean this up would be much appreciated. Thank you.