Regard - Datum Axis

Actually I want to Move all Datum Axis, Datum Plane, Datum Coordinates in to layer 51,
For that I wrote a code in Journal,
But When I run this NX journal it prompt it's not NX Open part type.
What should be the correction in my below Code. make things done.
Can you help me on this issue
'****************************************
Option Strict Off
Imports System
Imports NXOpen

Module Module9
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Dim Layno As Integer
Layno = 51

Dim datuma As DatumAxis
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()

For Each datuma As datuma In workPart.DatumAxis

displayModification1.NewLayer = Layno

Dim objects1(0) As DisplayableObject
objects1(0) = datuma
displayModification1.Apply(objects1)

Next

displayModification1.Dispose()

End Sub

End Module

Regard,
Gopal Parthasarathy

When using a "for each" loop, you can opt to use an existing variable as the loop variable or you can declare a temporary one right after the "for each" statement. If you want to use your existing "datuma" variable, the code would look like this:



Dim datuma as DatumAxis

For each datuma in workPart.Datums
...

If you prefer to create a temporary variable with scope limited to within the for loop, then you would use the syntax "For each [variable name] as [type]..."


Your current code uses: "For each [variable name] as [variable]..." which causes an error.




Also, it is worth noting that there is no dedicated DatumAxis collection in a part object. There is, however, a Datums collection that contains all the datum axes, planes, and points. You indicated that you want to move all of those objects to the same layer, in which case you might be able to use the following code:

Option Strict Off
Imports System
Imports NXOpen

Module Module10
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Dim Layno As Integer
Layno = 51

Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()

displayModification1.NewLayer = Layno

Dim objects1() As DisplayableObject
objects1 = workPart.Datums.ToArray

displayModification1.Apply(objects1)

displayModification1.Dispose()

End Sub

End Module

Thanks for the Code correction.
Suppose If I want to Move Datum Axis, Datum planes with diffrent layer.
is there any option to perform thorugh NX Journal.

Regards,
Gopal Parthasarathy

Gopal Parthasarathy
CERT/FEA Engineer
B/E Aerospace

You can test the type of each object and take action based on the object type.





For Each tempDatum As DisplayableObject In workPart.Datums

If TypeOf tempDatum Is DatumAxis Then
'code for Datum Axis objects
End If

If TypeOf tempDatum Is DatumPlane Then
'code for Datum Plane objects
End If

'test for other types as needed

Next





Keep in mind that a datum CSYS is made up of 3 datum axes, 3 datum planes, and a datum point. These objects will show up in the work part Datum collection separately. Moving datum axes and datum planes to separate layers indiscriminately may result in strange results for your datum CSYS objects. You may want to check if the datum in question is part of a datum csys feature and handle it differently than independent datum planes and axes.