Removing selection Stickiness from a Recorded NX Journal to "Add bend lines on Flat Pattern vie
Removing selection Stickiness from a Recorded NX Journal to "Add bend lines on Flat Pattern vie
(OP)
Hi,
I need help removing selection Stickiness from a Recorded NX Journal to "Add bend lines on Flat Pattern view in NX Drafting". Below is my recorded Journal Code for selecting that view and add bend lines through flat pattern setting. I want user to select the view using an UI and automatically add bend lines on that view selected by user. Need help modifying this code below. Thanks in advance.
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->Style...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")
theSession.SetUndoMarkName(markId1, "Class Selection Dialog")
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Class Selection")
theSession.DeleteUndoMark(markId2, Nothing)
theSession.SetUndoMarkName(markId1, "Class Selection")
theSession.DeleteUndoMark(markId1, Nothing)
' ----------------------------------------------
' Dialog Begin View Style
' ----------------------------------------------
Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "View Style")
Dim baseView1 As Drawings.BaseView = CType(workPart.DraftingViews.FindObject("FLAT-PATTERN#1@18"), Drawings.BaseView)
Dim flatPatternSettings1 As SheetMetal.FlatPatternSettings
flatPatternSettings1 = baseView1.Style.FlatPattern.GetPropertiesObject()
Dim displaydata1 As SheetMetal.FlatPatternSettings.FlatPatternObjectTypeDisplay
displaydata1.Type = SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendUpCenterLine
displaydata1.IsEnabled = 1
displaydata1.Color = workPart.Colors.Find("Background")
displaydata1.Font = ViewDependentDisplayManager.Font.Dashed
displaydata1.Width = -1
flatPatternSettings1.SetFlatPatternObjectTypeDisplay(SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendUpCenterLine, displaydata1)
Dim displaydata2 As SheetMetal.FlatPatternSettings.FlatPatternObjectTypeDisplay
displaydata2.Type = SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendDownCenterLine
displaydata2.IsEnabled = 1
displaydata2.Color = workPart.Colors.Find("Background")
displaydata2.Font = ViewDependentDisplayManager.Font.Dashed
displaydata2.Width = -1
flatPatternSettings1.SetFlatPatternObjectTypeDisplay(SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendDownCenterLine, displaydata2)
baseView1.Style.FlatPattern.Commit()
baseView1.Commit()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
Thanks
FJ
I need help removing selection Stickiness from a Recorded NX Journal to "Add bend lines on Flat Pattern view in NX Drafting". Below is my recorded Journal Code for selecting that view and add bend lines through flat pattern setting. I want user to select the view using an UI and automatically add bend lines on that view selected by user. Need help modifying this code below. Thanks in advance.
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->Style...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")
theSession.SetUndoMarkName(markId1, "Class Selection Dialog")
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Class Selection")
theSession.DeleteUndoMark(markId2, Nothing)
theSession.SetUndoMarkName(markId1, "Class Selection")
theSession.DeleteUndoMark(markId1, Nothing)
' ----------------------------------------------
' Dialog Begin View Style
' ----------------------------------------------
Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "View Style")
Dim baseView1 As Drawings.BaseView = CType(workPart.DraftingViews.FindObject("FLAT-PATTERN#1@18"), Drawings.BaseView)
Dim flatPatternSettings1 As SheetMetal.FlatPatternSettings
flatPatternSettings1 = baseView1.Style.FlatPattern.GetPropertiesObject()
Dim displaydata1 As SheetMetal.FlatPatternSettings.FlatPatternObjectTypeDisplay
displaydata1.Type = SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendUpCenterLine
displaydata1.IsEnabled = 1
displaydata1.Color = workPart.Colors.Find("Background")
displaydata1.Font = ViewDependentDisplayManager.Font.Dashed
displaydata1.Width = -1
flatPatternSettings1.SetFlatPatternObjectTypeDisplay(SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendUpCenterLine, displaydata1)
Dim displaydata2 As SheetMetal.FlatPatternSettings.FlatPatternObjectTypeDisplay
displaydata2.Type = SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendDownCenterLine
displaydata2.IsEnabled = 1
displaydata2.Color = workPart.Colors.Find("Background")
displaydata2.Font = ViewDependentDisplayManager.Font.Dashed
displaydata2.Width = -1
flatPatternSettings1.SetFlatPatternObjectTypeDisplay(SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendDownCenterLine, displaydata2)
baseView1.Style.FlatPattern.Commit()
baseView1.Commit()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
Thanks
FJ





RE: Removing selection Stickiness from a Recorded NX Journal to "Add bend lines on Flat Pattern vie
Thanks
FJ
RE: Removing selection Stickiness from a Recorded NX Journal to "Add bend lines on Flat Pattern vie
That said, below is some code to add a selection function to your journal:
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Dim theSession As Session = Session.GetSession() Dim theUfSession As UFSession = UFSession.GetUFSession() Dim theUI As UI = UI.GetUI() Dim lw As ListingWindow = theSession.ListingWindow Sub Main() Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "flat pattern view settings") lw.Open() Dim selectedView As Drawings.BaseView = Nothing If SelectBaseView(selectedView) = Selection.Response.Cancel Then Return End If Dim flatPatternSettings1 As SheetMetal.FlatPatternSettings flatPatternSettings1 = selectedView.Style.FlatPattern.GetPropertiesObject() Dim displaydata1 As SheetMetal.FlatPatternSettings.FlatPatternObjectTypeDisplay displaydata1.Type = SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendUpCenterLine displaydata1.IsEnabled = 1 displaydata1.Color = theSession.Parts.Work.Colors.Find("Background") displaydata1.Font = ViewDependentDisplayManager.Font.Dashed displaydata1.Width = -1 flatPatternSettings1.SetFlatPatternObjectTypeDisplay(SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendUpCenterLine, displaydata1) Dim displaydata2 As SheetMetal.FlatPatternSettings.FlatPatternObjectTypeDisplay displaydata2.Type = SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendDownCenterLine displaydata2.IsEnabled = 1 displaydata2.Color = theSession.Parts.Work.Colors.Find("Background") displaydata2.Font = ViewDependentDisplayManager.Font.Dashed displaydata2.Width = -1 flatPatternSettings1.SetFlatPatternObjectTypeDisplay(SheetMetal.FlatPatternSettings.FlatPatternObjectType.BendDownCenterLine, displaydata2) selectedView.Style.FlatPattern.Commit() selectedView.Commit() lw.Close() End Sub Function SelectBaseView(ByRef selObj As TaggedObject) As Selection.Response Dim theUI As UI = UI.GetUI Dim title As String = "Select flat pattern view" Dim prompt As String = "Select flat pattern view" Dim includeFeatures As Boolean = False Dim keepHighlighted As Boolean = False Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific Dim cursor As Point3d Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart Dim selectionMask_array(0) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_view_type .Subtype = UFConstants.UF_all_subtype End With Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, title, scope, selAction, includeFeatures, keepHighlighted, selectionMask_array, selObj, cursor) If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image immediately after execution within NX GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately End Function End Modulewww.nxjournaling.com
RE: Removing selection Stickiness from a Recorded NX Journal to "Add bend lines on Flat Pattern vie
FJ