erpj
Aerospace
- Jul 15, 2011
- 24
Hi everyone,
I wrote a journal (mainly by combining bits and pieces on this very forum) that creates a "START" attribute for each selected component in an assembly.
My problem is that my journal does not show any visual cue of what component is having its start attribute created/modified while it is happening.
Is there a way to select a specific component (or give any other visual feedback) during the journal execution?
Any help would be greatly appreciated.
Thanks!
Etienne
NX7.5.4.4 + TC Unified 8.3.2
I wrote a journal (mainly by combining bits and pieces on this very forum) that creates a "START" attribute for each selected component in an assembly.
My problem is that my journal does not show any visual cue of what component is having its start attribute created/modified while it is happening.
Is there a way to select a specific component (or give any other visual feedback) during the journal execution?
Any help would be greatly appreciated.
Thanks!
Code:
'NXJournaling
'2014-06-19
'Etiennovski
'This program will ask the user to select one (or multiple) component(s) and then cycle thru each one of those
'and ask for a new value for the "START" attribute. 1 = true, 0 = false
' NOTE: If the attribute does not exist, the program will create it.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies
Module create_or_update_START_ATTRIBUTE
Sub Main()
'---INITIALYZING ALL RELEVANT VARIABLES
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
'lw.Open()
Dim myComponents() As TaggedObject
If SelectComponents("Select components", myComponents) = Selection.Response.Cancel Then
Return
End If
For Each tempComp As Component In myComponents
Try
'---PERFORM OPERATION IF BOOLEAN ALREADY EXISTS
Dim myCompAttr As String
'assign attribute to string variable, change "attribute_title" as needed
myCompAttr = tempcomp.GetStringAttribute("START")
'write string variable to listing window
'lw.WriteLine("Attribute Value: " & myCompAttr)
'lw.WriteLine("")
Catch ex As NXException
'---BOOLEAN DID NOT EXIST SO WE CREATE IT
If ex.ErrorCode = 512008 Then
'MsgBox("The attribute does not exists, let's create it!")
'---------------------------------
Dim objects(0) As NXObject
objects(0) = tempcomp
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = workpart.PropertiesManager.CreateAttributePropertiesBuilder(objects)
attributePropertiesBuilder1.ObjectPicker = AttributePropertiesBaseBuilder.ObjectOptions.ComponentInstance
attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.Boolean
attributePropertiesBuilder1.Title = "START"
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.BooleanValue = 1
Dim nXObject2 As NXObject
nXObject2 = attributePropertiesBuilder1.Commit()
attributePropertiesBuilder1.Destroy()
'---------------------------------
Else
MsgBox(ex.ErrorCode.ToString & " : " & ex.Message)
End If
End Try
Dim newStr as String
Dim defAns as String
Dim newBool as Boolean
newStr="sup"
newBool = tempcomp.GetStringAttribute("START")
If newBool Then
defAns=1
Else
defAns=0
End If
Do While (newStr<>"1" And newStr<>"0")
REM newBool =
newStr=InputBox("Component is at the start? (1/0)", "START attribute definition", defAns)
if newStr = "" then
'null string means cancel was pressed, exit journal
Continue Do
end if
'---BASED ON USER ANSWER WE UPDATE THE ATTRIBUTE
Dim objects(0) As NXObject
objects(0) = tempcomp
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = workpart.PropertiesManager.CreateAttributePropertiesBuilder(objects)
attributePropertiesBuilder1.ObjectPicker = AttributePropertiesBaseBuilder.ObjectOptions.ComponentInstance
attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.Boolean
attributePropertiesBuilder1.Title = "START"
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.BooleanValue = newStr
Dim nXObject2 As NXObject
nXObject2 = attributePropertiesBuilder1.Commit()
attributePropertiesBuilder1.Destroy()
Loop
Next
End Sub
Function SelectComponents(ByVal prompt As String, ByRef selObj() As TaggedObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select components"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
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_component_subtype
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj)
If resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Function SelectSpecificComponent(myComponent) As Selection.Response
'???????????????????
End Function
Function UnselectAllComponents() As Selection.Response
'???????????????????
End Function
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 Module
Etienne
NX7.5.4.4 + TC Unified 8.3.2