×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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


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

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

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

(OP)
Thanks cowski, this worked perfectly.

FJ

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources