Actually I want to move sketeches to the layer 101, 102,... and so on
Suppose my part model has three sketches SKT_000,SKT_001,& SKT_002
My NX journal select first sketch "SKT_000" to move into layer 101, like wise SKT_001 to 102 and SKT_002 to 103
I have made below code for the task, but i couldn't make it.
Can any one help for the correction of below one.
*****************************************************
Option Strict Off
Imports System
Imports NXOpen
Module Module1
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 = 101
For Each ts As Sketch In workPart.Sketches
ts.Activate(Sketch.ViewReorient.False)
ts.layer.set = layno
layno = layno+1
Next
End Sub
End Module
*********************************************
Regards,
Gopal Parthasarathy
+91 7799221856
Regard - layer Get and set layer
Option Strict Off
Imports System
Imports NXOpen
Module Module1
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 =101
For Each ts As Sketch In workPart.Sketches
ts.Activate(Sketch.ViewReorient.False)
ts.layer.set = layno
layno = layno+1
Next
End Sub
End Module
Gopal Parthasarathy
CERT/FEA Engineer
B/E Aerospace
re: move sketch to layer
After you set the layer, you will need to call the .RedisplayObject method and perform an update. An easier way is to use the DisplayModification object as follows:
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 = 101
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
For Each ts As Sketch In workPart.Sketches
displayModification1.NewLayer = Layno
Dim objects1(0) As DisplayableObject
objects1(0) = ts
displayModification1.Apply(objects1)
Layno += 1
Next
displayModification1.Dispose()
End Sub
End Module
Tidier object array code
You can write the displayModification code in a slightly tidier way using VB's ability to construct arrays on the fly. For example, you could write:
Dim objects1 As DisplayableObject() = {ts}
displayModification1.Apply(objects1)
Or even just this:
displayModification1.Apply({ts})
re: tidy array code
Good tip!
Thanks ciao.