Kenja824
Automotive
- Nov 5, 2014
- 949
I have the below code someone had given me in the past to add attributes to a file.
Could someone please explain how to adjust this so that all of the attributes are added to a category? Say give the Category the name "CONTROLS" for whatever it is worth.
So that when someone opens the file properties, there will be a new category named "CONTROLS" and all of these attributes would be inside of that category.
Dim TheSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim WorkPart As Part = TheSession.Parts.Work
Sub Main(ByVal args() As String)
' Public Sub Initialize()
For Each KP As KeyValuePair(Of String, String) In Attributes
If Not TheSession.Parts.Work.HasUserAttribute(KP.Key, NXObject.AttributeType.Any, -1) Then
TheSession.Parts.Work.SetUserAttribute(KP.Key, -1, KP.Value, Update.Option.Now)
TheSession.ListingWindow.Open()
TheSession.ListingWindow.WriteFullline(String.Format("Creating / Writing Attribute: {0} = {1}", KP.Key, KP.Value))
End If
Next
End Sub
Public ReadOnly Property Attributes As Dictionary(Of String, String)
Get
Dim Dict As New Dictionary(Of String, String)
Dict.Add("Build Source", "")
Dict.Add("Checked By", "")
Dict.Add("Checked Date", "")
Dict.Add("Consumable", "")
Dict.Add("Customer", "")
Dict.Add("Designed By", "")
Dict.Add("Detail Number", "")
Dict.Add("FCA Detail Number", "")
Dict.Add("FCA NPM Code", "")
Dict.Add("FCA Plant Name", "")
Dict.Add("FCA Tool Number (Opposite)", "")
Dict.Add("FCA Tool Number (Shown)", "")
Dict.Add("Job Number", "")
Dict.Add("Line Assy Name", "")
Dict.Add("Line Assy Number", "")
Dict.Add("Manufacturer Name", "")
Dict.Add("Manufacturer Part Number", "")
Dict.Add("Model Year", "")
Dict.Add("NX_ObjectMaterial", "")
Dict.Add("OPP QTY", "")
Dict.Add("Paint Code", "")
Dict.Add("Program", "")
Return Dict
End Get
End Property
End Module
Could someone please explain how to adjust this so that all of the attributes are added to a category? Say give the Category the name "CONTROLS" for whatever it is worth.
So that when someone opens the file properties, there will be a new category named "CONTROLS" and all of these attributes would be inside of that category.
Dim TheSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim WorkPart As Part = TheSession.Parts.Work
Sub Main(ByVal args() As String)
' Public Sub Initialize()
For Each KP As KeyValuePair(Of String, String) In Attributes
If Not TheSession.Parts.Work.HasUserAttribute(KP.Key, NXObject.AttributeType.Any, -1) Then
TheSession.Parts.Work.SetUserAttribute(KP.Key, -1, KP.Value, Update.Option.Now)
TheSession.ListingWindow.Open()
TheSession.ListingWindow.WriteFullline(String.Format("Creating / Writing Attribute: {0} = {1}", KP.Key, KP.Value))
End If
Next
End Sub
Public ReadOnly Property Attributes As Dictionary(Of String, String)
Get
Dim Dict As New Dictionary(Of String, String)
Dict.Add("Build Source", "")
Dict.Add("Checked By", "")
Dict.Add("Checked Date", "")
Dict.Add("Consumable", "")
Dict.Add("Customer", "")
Dict.Add("Designed By", "")
Dict.Add("Detail Number", "")
Dict.Add("FCA Detail Number", "")
Dict.Add("FCA NPM Code", "")
Dict.Add("FCA Plant Name", "")
Dict.Add("FCA Tool Number (Opposite)", "")
Dict.Add("FCA Tool Number (Shown)", "")
Dict.Add("Job Number", "")
Dict.Add("Line Assy Name", "")
Dict.Add("Line Assy Number", "")
Dict.Add("Manufacturer Name", "")
Dict.Add("Manufacturer Part Number", "")
Dict.Add("Model Year", "")
Dict.Add("NX_ObjectMaterial", "")
Dict.Add("OPP QTY", "")
Dict.Add("Paint Code", "")
Dict.Add("Program", "")
Return Dict
End Get
End Property
End Module