moog2
Mechanical
- Jan 16, 2007
- 441
Could someone please help modify this journal to run in an assembly.
I've got hundreds of files to run it on, and it'd be much better if the journal could run from the top level assembly, looking for all files with this expression, and adding the linked attribute accordingly.
This is so I can export to a spreadsheet the assembly navigator info with the sheet metal thickness in there too.
Any help much appreciated......
' NX 8.0.3.4
' Journal created by paulhorton on Fri Jan 29 10:28:58 2016 E. Australia 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: File->Properties
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
Dim objects1(0) As NXObject
objects1(0) = workPart
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = workPart.PropertiesManager.CreateAttributePropertiesBuilder(objects1)
attributePropertiesBuilder1.ObjectPicker = AttributePropertiesBaseBuilder.ObjectOptions.Object
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.String
attributePropertiesBuilder1.Units = "MilliMeter"
Dim objects2(0) As NXObject
objects2(0) = workPart
Dim massPropertiesBuilder1 As MassPropertiesBuilder
massPropertiesBuilder1 = workPart.PropertiesManager.CreateMassPropertiesBuilder(objects2)
Dim selectNXObjectList1 As SelectNXObjectList
selectNXObjectList1 = massPropertiesBuilder1.SelectedObjects
Dim objects3() As NXObject
objects3 = selectNXObjectList1.GetArray()
massPropertiesBuilder1.UpdateOnSave = MassPropertiesBuilder.UpdateOptions.Yes
massPropertiesBuilder1.LoadPartialComponents = True
massPropertiesBuilder1.Accuracy = 0.99
Dim objects4(0) As NXObject
objects4(0) = workPart
Dim previewPropertiesBuilder1 As PreviewPropertiesBuilder
previewPropertiesBuilder1 = workPart.PropertiesManager.CreatePreviewPropertiesBuilder(objects4)
theSession.SetUndoMarkName(markId1, "Displayed Part Properties Dialog")
attributePropertiesBuilder1.DateValue.DateItem.Day = DateItemBuilder.DayOfMonth.Day29
attributePropertiesBuilder1.DateValue.DateItem.Month = DateItemBuilder.MonthOfYear.Jan
attributePropertiesBuilder1.DateValue.DateItem.Year = "2016"
attributePropertiesBuilder1.DateValue.DateItem.Time = "00:00:00"
attributePropertiesBuilder1.Units = "MilliMeter"
previewPropertiesBuilder1.StorePartPreview = True
previewPropertiesBuilder1.StoreModelViewPreview = True
previewPropertiesBuilder1.ModelViewCreation = PreviewPropertiesBuilder.ModelViewCreationOptions.OnViewSave
attributePropertiesBuilder1.Category = "Materials"
attributePropertiesBuilder1.Title = "thickness"
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.Number
attributePropertiesBuilder1.Units = "MilliMeter"
' ----------------------------------------------
' Dialog Begin Expressions
' ----------------------------------------------
attributePropertiesBuilder1.Units = "MilliMeter"
attributePropertiesBuilder1.Units = "MilliMeter"
attributePropertiesBuilder1.NumberValue = 4.0
attributePropertiesBuilder1.IsReferenceType = False
Dim expression1 As Expression = CType(workPart.Expressions.FindObject("Sheet_Metal_Material_Thickness"), Expression)
attributePropertiesBuilder1.Expression = expression1
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Displayed Part Properties")
Dim nXObject1 As NXObject
nXObject1 = attributePropertiesBuilder1.Commit()
Dim updateoption1 As MassPropertiesBuilder.UpdateOptions
updateoption1 = massPropertiesBuilder1.UpdateOnSave
Dim nXObject2 As NXObject
nXObject2 = massPropertiesBuilder1.Commit()
workPart.PartPreviewMode = BasePart.PartPreview.OnSave
Dim nXObject3 As NXObject
nXObject3 = previewPropertiesBuilder1.Commit()
theSession.DeleteUndoMark(markId2, Nothing)
theSession.SetUndoMarkName(markId1, "Displayed Part Properties")
attributePropertiesBuilder1.Destroy()
massPropertiesBuilder1.Destroy()
previewPropertiesBuilder1.Destroy()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
I've got hundreds of files to run it on, and it'd be much better if the journal could run from the top level assembly, looking for all files with this expression, and adding the linked attribute accordingly.
This is so I can export to a spreadsheet the assembly navigator info with the sheet metal thickness in there too.
Any help much appreciated......
' NX 8.0.3.4
' Journal created by paulhorton on Fri Jan 29 10:28:58 2016 E. Australia 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: File->Properties
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
Dim objects1(0) As NXObject
objects1(0) = workPart
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = workPart.PropertiesManager.CreateAttributePropertiesBuilder(objects1)
attributePropertiesBuilder1.ObjectPicker = AttributePropertiesBaseBuilder.ObjectOptions.Object
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.String
attributePropertiesBuilder1.Units = "MilliMeter"
Dim objects2(0) As NXObject
objects2(0) = workPart
Dim massPropertiesBuilder1 As MassPropertiesBuilder
massPropertiesBuilder1 = workPart.PropertiesManager.CreateMassPropertiesBuilder(objects2)
Dim selectNXObjectList1 As SelectNXObjectList
selectNXObjectList1 = massPropertiesBuilder1.SelectedObjects
Dim objects3() As NXObject
objects3 = selectNXObjectList1.GetArray()
massPropertiesBuilder1.UpdateOnSave = MassPropertiesBuilder.UpdateOptions.Yes
massPropertiesBuilder1.LoadPartialComponents = True
massPropertiesBuilder1.Accuracy = 0.99
Dim objects4(0) As NXObject
objects4(0) = workPart
Dim previewPropertiesBuilder1 As PreviewPropertiesBuilder
previewPropertiesBuilder1 = workPart.PropertiesManager.CreatePreviewPropertiesBuilder(objects4)
theSession.SetUndoMarkName(markId1, "Displayed Part Properties Dialog")
attributePropertiesBuilder1.DateValue.DateItem.Day = DateItemBuilder.DayOfMonth.Day29
attributePropertiesBuilder1.DateValue.DateItem.Month = DateItemBuilder.MonthOfYear.Jan
attributePropertiesBuilder1.DateValue.DateItem.Year = "2016"
attributePropertiesBuilder1.DateValue.DateItem.Time = "00:00:00"
attributePropertiesBuilder1.Units = "MilliMeter"
previewPropertiesBuilder1.StorePartPreview = True
previewPropertiesBuilder1.StoreModelViewPreview = True
previewPropertiesBuilder1.ModelViewCreation = PreviewPropertiesBuilder.ModelViewCreationOptions.OnViewSave
attributePropertiesBuilder1.Category = "Materials"
attributePropertiesBuilder1.Title = "thickness"
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.Number
attributePropertiesBuilder1.Units = "MilliMeter"
' ----------------------------------------------
' Dialog Begin Expressions
' ----------------------------------------------
attributePropertiesBuilder1.Units = "MilliMeter"
attributePropertiesBuilder1.Units = "MilliMeter"
attributePropertiesBuilder1.NumberValue = 4.0
attributePropertiesBuilder1.IsReferenceType = False
Dim expression1 As Expression = CType(workPart.Expressions.FindObject("Sheet_Metal_Material_Thickness"), Expression)
attributePropertiesBuilder1.Expression = expression1
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Displayed Part Properties")
Dim nXObject1 As NXObject
nXObject1 = attributePropertiesBuilder1.Commit()
Dim updateoption1 As MassPropertiesBuilder.UpdateOptions
updateoption1 = massPropertiesBuilder1.UpdateOnSave
Dim nXObject2 As NXObject
nXObject2 = massPropertiesBuilder1.Commit()
workPart.PartPreviewMode = BasePart.PartPreview.OnSave
Dim nXObject3 As NXObject
nXObject3 = previewPropertiesBuilder1.Commit()
theSession.DeleteUndoMark(markId2, Nothing)
theSession.SetUndoMarkName(markId1, "Displayed Part Properties")
attributePropertiesBuilder1.Destroy()
massPropertiesBuilder1.Destroy()
previewPropertiesBuilder1.Destroy()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module