VB.NET To create part attributes
VB.NET To create part attributes
(OP)
I need to create a lot of part attributes. I am trying to use 'setattribute' within a journal to create the variable and the value, but can't seem to set the category. Is it possible with 'setattribute' or should I use something else?
I would like to separate the attributes into logical groups 'Design, Manufacture, Inspection' ect
Thanks in advance,
NX Jockey
I would like to separate the attributes into logical groups 'Design, Manufacture, Inspection' ect
Thanks in advance,
NX Jockey





RE: VB.NET To create part attributes
See the above link.
RE: VB.NET To create part attributes
CODE --> vb.net
'Created By Jeremy Shooks 'Create attributes from DB_part_name '6-23-2017 Option Strict Off Imports System Imports NXOpen Imports System.Collections.Generic Imports System.Windows.Forms Imports NXOpenUI Module NXJournal Sub Main (ByVal args() As String) Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim displayPart As Part = theSession.Parts.Display ' ---------------------------------------------- ' Menu: Tools->Expressions... ' ---------------------------------------------- theSession.Preferences.Modeling.UpdatePending = False Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") Dim expressionDBPartName As Expression expressionDBPartName = workPart.Expressions.CreateExpression("String", "TCeName=ug_askPartAttrValue(""DB_part_name"")") Dim expressionTCeName As Expression expressionTCeName = workPart.Expressions.CreateExpression("List", "TCeNameList=splitstring(TCeName, ""-"")") Dim expressionLength As Expression expressionLength = workPart.Expressions.CreateExpression("Integer", "TCeNameListLength=length(TCeNameList)") Dim expressionMMProjectNumber As Expression expressionMMProjectNumber = workPart.Expressions.CreateExpression("String", "MM_ProjectNumber=nth(1, TCeNameList)") Dim expressionMMPartNumber As Expression expressionMMPartNumber = workPart.Expressions.CreateExpression("String", "MM_partNumber=nth(2, TCeNameList)") Dim expressionMMName As Expression expressionMMName = workPart.Expressions.CreateExpression("String", "MM_NAME=nth(3, TCeNameList)") Dim expressionMMHand As Expression expressionMMHand = workPart.Expressions.CreateExpression("String", "MM_Hand=nth(4, TCeNameList)") Dim expressionMMType As Expression expressionMMType = workPart.Expressions.CreateExpression("String", "MM_Type =nth(5, TCeNameList)") ' ---------------------------------------------- ' Expressions to attribute link ' ---------------------------------------------- Dim objects1(0) As NXObject objects1(0) = workPart Dim attributePropertiesBuilder1 As AttributePropertiesBuilder attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects1, AttributePropertiesBuilder.OperationType.None) attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.String Dim objectsEXP(0) As NXObject objectsEXP(0) = workPart attributePropertiesBuilder1.SetAttributeObjects(objectsEXP) Dim changed1 As Boolean '------------MM_Hand------- attributePropertiesBuilder1.Category = "MM" attributePropertiesBuilder1.Title = "MM_Hand" attributePropertiesBuilder1.StringValue = "" attributePropertiesBuilder1.IsReferenceType = False attributePropertiesBuilder1.Expression = expressionMMHand changed1 = attributePropertiesBuilder1.CreateAttribute() '------------MM_Type------- attributePropertiesBuilder1.Category = "MM" attributePropertiesBuilder1.Title = "MM_Type" attributePropertiesBuilder1.StringValue = "" attributePropertiesBuilder1.IsReferenceType = False attributePropertiesBuilder1.Expression = expressionMMType changed1 = attributePropertiesBuilder1.CreateAttribute() '------------MM_Name------- attributePropertiesBuilder1.Category = "MM" attributePropertiesBuilder1.Title = "MM_PART_DESCRIPTION" attributePropertiesBuilder1.StringValue = "" attributePropertiesBuilder1.IsReferenceType = False attributePropertiesBuilder1.Expression = expressionMMName changed1 = attributePropertiesBuilder1.CreateAttribute() '------------MM_PartNumber------- attributePropertiesBuilder1.Category = "MM" attributePropertiesBuilder1.Title = "MM_Part_Number" attributePropertiesBuilder1.StringValue = "" attributePropertiesBuilder1.IsReferenceType = False attributePropertiesBuilder1.Expression = expressionMMPartNumber changed1 = attributePropertiesBuilder1.CreateAttribute() '------------MM_ProjectNumber------ attributePropertiesBuilder1.Category = "MM" attributePropertiesBuilder1.Title = "MM_Project_Number" attributePropertiesBuilder1.StringValue = "" attributePropertiesBuilder1.IsReferenceType = False attributePropertiesBuilder1.Expression = expressionMMProjectNumber changed1 = attributePropertiesBuilder1.CreateAttribute() End Sub End Module