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!

Journaling Generic FindObject

Status
Not open for further replies.

CaseNTray

Mechanical
Jan 9, 2012
10
I have created a journal to export geo files for our sheet metal parts, but I need to make it generic so I can run it on different parts. I’ve been looking thru here the past couple of days trying to find specifics on how to accomplish this with no success, several threads come close but I am not able to cross I’s & dot T’s. In this example I know I need to change "FLAT_PATTERN(10)" to something generic and I would like it to export the geo file name as the part file name. Is there a source that someone can recommend for specific journaling details? Thanks!


' NX 7.5.5.4
' Journal created by bradg on Fri Feb 13 14:19:30 2015 Eastern Standard Time
'
Option Strict Off
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: Insert->Flat Pattern->Export Trumpf GEO File
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim exportTrumpfBuilder1 As Features.SheetMetal.ExportTrumpfBuilder
exportTrumpfBuilder1 = workPart.Features.SheetmetalManager.CreateExportTrumpfBuilder()

exportTrumpfBuilder1.OutputGeoFile = "C:\DXF\model0.geo"

exportTrumpfBuilder1.InteriorCutout = True

theSession.SetUndoMarkName(markId1, "Export Trumpf GEO File Dialog")

Dim flatPattern1 As Features.FlatPattern = CType(workPart.Features.FindObject("FLAT_PATTERN(10)"), Features.FlatPattern)

exportTrumpfBuilder1.SelectFlatPattern.Value = flatPattern1

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Export Trumpf GEO File")

Dim nXObject1 As NXObject
nXObject1 = exportTrumpfBuilder1.Commit()

theSession.DeleteUndoMark(markId2, Nothing)

theSession.SetUndoMarkName(markId1, "Export Trumpf GEO File")

exportTrumpfBuilder1.Destroy()

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module
 
Replies continue below

Recommended for you

I'm not a big sheet metal user, but the last time I worked with it I think there was only a single flat pattern feature allowed per file. If this is still the case, we can simply iterate through the feature list looking for the flat pattern feature. If this is no longer the case and there can be multiple flat pattern features, which one do you want to use (first found, last found, other)?

www.nxjournaling.com
 
You can have multiple flat patterns however our parts always only have a single flat pattern.
 
Try this (only tested on 1 simple part):

Code:
Option Strict Off
Imports System
Imports NXOpen

Module Module28

    Dim theSession As Session = Session.GetSession()
    Dim workPart As Part = theSession.Parts.Work

    Sub Main()

        'find flat pattern feature
        For Each tempFeature As Features.Feature In workPart.Features
            If TypeOf (tempFeature) Is Features.FlatPattern Then
                'found it!
                ExportTrumpf(workPart.FullPath.Substring(0, workPart.FullPath.Length - 4) & ".geo", tempFeature)
                Exit For
            End If
        Next

    End Sub

    Sub ExportTrumpf(ByVal exportFileName As String, ByVal flatPattern As Features.FlatPattern)

        Dim exportTrumpfBuilder1 As Features.SheetMetal.ExportTrumpfBuilder
        exportTrumpfBuilder1 = Workpart.Features.SheetmetalManager.CreateExportTrumpfBuilder()

        exportTrumpfBuilder1.OutputGeoFile = exportFileName

        exportTrumpfBuilder1.InteriorCutout = True

        exportTrumpfBuilder1.SelectFlatPattern.Value = flatPattern

        Dim nXObject1 As NXObject
        nXObject1 = exportTrumpfBuilder1.Commit()

        exportTrumpfBuilder1.Destroy()

    End Sub

End Module

www.nxjournaling.com
 
As you suspected, you need to get rid of the "FindObject" calls, and replace them with something more suitable. There's a decent description of the various ways to do in the Getting Started with SNAP guide. The section is entitled "The FindObject Problem". I think it's in chapter 16. The description there applies to NX/Open, too, not just to SNAP.
 
Thanks Cowski this works great! I am in the process of changing our macros to journals and there a few others I can apply this to!

Is the Getting Started with SNAP guide part of the NX help files or do I need to download that from GTAC?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor