Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing selection Stickiness from a Recorded NX Journal to "Add bend lines on Flat Pattern vie

Status
Not open for further replies.

mdfathmi

Mechanical
Apr 22, 2016
7
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


 
Replies continue below

Recommended for you

If you want the bend lines on your flat pattern views, consider changing your template files and/or customer defaults so that they are included when the view is created.

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 Module

www.nxjournaling.com
 
Thanks cowski, this worked perfectly.

FJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor