Journals and Part Templates
Journals and Part Templates
(OP)
I have a journal that creates a basic assembly based on some user inputs. How do I point my journal to use a specific template file for creating the new components? And, where do I need to save my template file?
Change fileNew1.TemplateFileName = "assembly-mm-template.prt" to fileNew1.TemplateFileName = "My_Template.prt" ?
Is this the proper location to save new templates? NX 8.0\UGII\templates
Any information on this would be greatly appreciated!
Thanks,
Kevin
NX8
Change fileNew1.TemplateFileName = "assembly-mm-template.prt" to fileNew1.TemplateFileName = "My_Template.prt" ?
Is this the proper location to save new templates? NX 8.0\UGII\templates
Any information on this would be greatly appreciated!
Thanks,
Kevin
NX8





RE: Journals and Part Templates
The following code will show what files you currently have set up as templates.
CODE
Option Strict Off Imports System Imports NXOpen Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim templates() As String templates = theSession.Parts.FileNew.GetAvailableTemplates For Each temp As String In templates lw.WriteLine(temp) Next lw.Close() End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination End Function End Modulewww.nxjournaling.com
RE: Journals and Part Templates
Sorry for the delay. I ran your program and my template was in the list.
Below is a portion of the program, i can supply the rest if you need it to make sense of it.
The program errors out when I check to see if the file already exists before committing.
I get the "File already exists, Exiting" message, and I have double checked that the file does not exist.
Thanks,
Kevin
' -----------------------------------------------------------------------------------------------------------
' Menu: File->New...
' -----------------------------------------------------------------------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
Dim fileNew1 As FileNew
fileNew1 = theSession.Parts.FileNew()
fileNew1.TemplateFileName = "Sim_Template.prt"
fileNew1.Application = FileNewApplication.Assemblies
fileNew1.Units = Part.Units.Millimeters
fileNew1.TemplateType = FileNewTemplateType.Item
fileNew1.NewFileName = FilePath+"\"+JobNumber+"_Sim_000.prt"
fileNew1.MasterFileName = ""
fileNew1.UseBlankTemplate = False
fileNew1.MakeDisplayedPart = True
Dim nXObject1 As NXObject
lw.Open
lw.WriteLine(fileNew1.NewFileName.ToString)
lw.WriteLine(fileNew1.TemplateFileName.ToString)
lw.Close
'---------------Checking to see if file exists before trying to commit--------------------------------------
Try
nXObject1 = fileNew1.Commit()
Catch ex As NXException
MessageBox.Show("File already exists, Exiting")
Exit Sub
End Try
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
fileNew1.Destroy()
RE: Journals and Part Templates
Also, for more information on your specific error, try printing the error message rather than the generic string "File already exists, exiting".
CODE
Try nXObject1 = fileNew1.Commit() Catch ex As NXExceptionMessageBox.Show("File already exists, Exiting")MessageBox.Show(ex.message) Exit Sub End Trywww.nxjournaling.com
RE: Journals and Part Templates
Thanks for the information, I will research the .Validate.
Right now I am trying to figure out where NX is pulling the template file from.
Kevin
RE: Journals and Part Templates
Any ideas??
Thanks,
Kevin
RE: Journals and Part Templates