Quantcast
Viewing all articles
Browse latest Browse all 5175

Part Family Attributes in Assembly Instance

Hello,

So, I have a part family component with a few user attributes as follow:
Image may be NSFW.
Clik here to view.
attrs.JPG

 

My idea is read and change those parameters for each instance in one assembly. 
First I have the following journal to read those attributes, but I don't know why it's not working. What i'm doing wrong?

Inherited parameters like TOOL_ID I can read with no problem, but custom ones shows as "not existent"

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim mySelectedObject As NXObject
Dim answer,answer2 As String
lw.Open
'Continue prompting for a selection until the user
'  presses Cancel or Back.
'SelectComponent
answer = ""
answer2 = "" 
Do Until SelectComponent("Hey, select something", _
                       mySelectedObject) = Selection.Response.Cancel

	Dim attributeName As New List(Of String) 

	 attributeName.Add("TOOL_ID")
	attributeName.Add("THD_SIZE/P")
	attributeName.Add("STD_SCR_LG")
	attributeName.Add("DB_PART_NO")
	attributeName.Add("DB_PART_DESC")
	attributeName.Add("C_id")
	attributeName.Add("C_angle")
	attributeName.Add("C_diam")
	attributeName.Add("C_state")
	attributeName.Add("C_stk")
	attributeName.Add("C_valve")
	attributeName.Add("S_id")
	attributeName.Add("S_type")
	attributeName.Add("S_size")
	attributeName.Add("S_model")	

      	Dim attributeInfo As New List(Of String)

		 
dim i as integer 

	for each atri as String in attributeName	
		i= attributeName.IndexOf (atri)
  	Try 
 		attributeInfo.Add(mySelectedObject.GetUserAttribute(attributeName(i), NXObject.AttributeType.String, -1).StringValue)
		lw.WriteLine(attributeName(i) & ": " & attributeInfo(i))

	Catch ex As Exception
		lw.WriteLine("The following attribute doesn't exist: " & atri)
	End Try
	next

Loop
 
lw.Close
 
End Sub

 
Function SelectComponent(ByVal prompt As String, ByRef selObj as TaggedObject) As Selection.Response
 
	Dim theUI as UI = UI.GetUI
	Dim theUfSession As UFSession = UFSession.GetUFSession()
	Dim title As String = "Select a component"
	Dim includeFeatures As Boolean = False
	Dim keepHighlighted As Boolean = False
	Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
	Dim cursor As Point3d
	Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
	Dim selectionMask_array(0) As Selection.MaskTriple
 
	With selectionMask_array(0)
		.Type = UFConstants.UF_component_type
		.Subtype = UFConstants.UF_instance_type
	End With

 	 theUfSession.Ui.SetCursorView(0)
	Dim resp as Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
		title, scope, selAction, _
		includeFeatures, keepHighlighted, selectionMask_array, _
		selobj, cursor)
	If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
		Return Selection.Response.Ok
	Else
		Return Selection.Response.Cancel
	End If
 
End Function

End Module

Thanks in advance


Viewing all articles
Browse latest Browse all 5175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>