Journal for exporting to part file
Journal for exporting to part file
(OP)
Looking to make an addition to a journal. Needing a portion of the journal to export all objects on a specific layer to a part file. This will be imported later, but I already have the code to do that. The number of objects is varied (and can be zero at times). Any help or link to the right code would be awesome. Thanks!





RE: Journal for exporting to part file
thread561-391289: Journal to export selected (multiple) bodies to temp part, and remove parameters
www.nxjournaling.com
RE: Journal for exporting to part file
The code is helping a lot. I'm doing some editing to it and came across a snag. The original files come from a certain folder number, labeled as xxxx-xxxx. I want these new part files to be saved in their respective folders as "xxxx-xxxx new part". How do I need to adjust or add to this line so that I don't have to manually move them from 'temp' (or any other location)?:
theUFSession.Part.ExportWithOptions("C:\temp\6118251.prt", bodyTags.Count, bodyTags.ToArray, options)
RE: Journal for exporting to part file
RE: Journal for exporting to part file
www.nxjournaling.com
RE: Journal for exporting to part file
It's been a while since I've posted, but the code that I have now is working great! Only thing that would make it better is if there was a way to have the journal automatically select all of the bodies on a certain layer (there will be no bodies sometimes) instead of having to select the bodies. Any advise?
CODE -->
RE: Journal for exporting to part file
thread561-332006: Uniting All Objects on a Layer
www.nxjournaling.com
RE: Journal for exporting to part file
CODE -->
Option Strict Off Imports System 'x Imports System.Collections.Generic 'x Imports NXOpen 'x Imports NXOpen.UF 'x Imports NXOpen.UI 'x Module NXJournal Dim theSession As Session = Session.GetSession() Dim theUFSession As UFSession = UFSession.GetUFSession() Dim currentPath as string Dim currentFile as string Dim workPart As Part = theSession.Parts.Work Dim displayPart As Part = theSession.Parts.Display Sub Main() currentPath = GetFilePath() currentFile = GetFileName() Dim abody() As TaggedObject Dim overlayExport As Integer = 190 Dim bodiesOnExportLayer As New List (Of Body) For Each temp As Body In workPart.Bodies If temp.IsSolidBody Then If temp.Layer = overlayExport Then bodiesOnExportLayer.Add(temp) End If End If Next Dim options As UFPart.ExportOptions With options .expression_mode = UFPart.ExportExpMode.CopyExpShallowly .new_part = True .params_mode = UFPart.ExportParamsMode.RemoveParams End With theUFSession.Part.ExportWithOptions(currentPath & "\" & currentFile & " crowns-overlay", bodiesOnExportLayer.Count, bodiesOnExportLayer.ToArray, options) End Sub Function SelectBodies(ByVal prompt As String, ByRef selObj() As Body) As Selection.Response Dim theUI As UI = UI.GetUI Dim title As String = "Select one or more bodies" Dim includeFeatures As Boolean = False Dim keepHighlighted As Boolean = False Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart Dim selectionMask_array(0) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_solid_type .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY End With Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, _ title, scope, selAction, _ includeFeatures, keepHighlighted, selectionMask_array, _ selobj) If resp = Selection.Response.Ok Then Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function Function GetFileName() Dim strPath as String Dim strPart as String Dim pos as Integer 'get the full file path strPath = displayPart.fullpath 'get the part file name pos = InStrRev(strPath, "\") strPart = Mid(strPath, pos + 1) strPath = Left(strPath, pos) 'strip off the ".prt" extension strPart = Left(strPart, Len(strPart) - 4) GetFileName = strPart End Function '*********************************************************************** Function GetFilePath() Dim strPath as String Dim strPart as String Dim pos as Integer Dim pos2 as Integer 'get the full file path strPath = displayPart.fullpath 'get the part file name pos = InStrRev(strPath, "\") strPart = Mid(strPath, pos + 1) strPath = Left(strPath, pos - 1) 'strip off the ".prt" extension strPart = Left(strPart, Len(strPart) - 4) 'pos2 = InStrRev(strPath, "\") 'strPath = Left(strPath, pos2) GetFilePath = strPath End Function End ModuleRE: Journal for exporting to part file
CODE
Dim bodiesOnExportLayer As New List (Of Tag) For Each temp As Body In workPart.Bodies If temp.IsSolidBody Then If temp.Layer = overlayExport Then bodiesOnExportLayer.Add(temp.Tag) End If End If Nextwww.nxjournaling.com
RE: Journal for exporting to part file
RE: Journal for exporting to part file
Will a similar journal be needed if I wanted to export a part to a .stl file?