Help in Journal Error
Help in Journal Error
(OP)
Hi
In this journal (that I revised from internet one) I get error in line 31
line 31 ==> attrInfo = body_object.GetUserAttribute("test",NXObject.AttributeType.String,-1)
Using NX8.5
What's wrong here
My goal is to read the body attribute (Title = Value) for a given title gets its value
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.UF
Module report_attrs_by_title_and_type
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Sub Main()
Dim body As NXOpen.Tag
While select_a_body(body) = Selection.Response.Ok
Dim loopVar As Integer = 0
Dim body_object As NXObject = CType(NXObjectManager.Get(body), NXObject)
MsgBox("Body Object:" & body_object.ToString())
Dim attrInfo As NXObject.AttributeInformation
Try
attrInfo = body_object.GetUserAttribute("test",NXObject.AttributeType.String,-1)
ufs.Ui.OpenListingWindow()
ufs.Ui.WriteListingWindow("Attribute Title: " & attrInfo.Title & vbCrLf)
ufs.Ui.WriteListingWindow("Attribute Type: " & attrInfo.Type.ToString & vbCrLf)
ufs.Ui.WriteListingWindow("Attribute StringValue: " & attrInfo.StringValue & vbCrLf)
Catch ex As Exception
MsgBox(ex.ToString(), MsgBoxStyle.Critical)
End Try
End While
End Sub
Function select_a_body(ByRef body As NXOpen.Tag) As Selection.Response
Dim message As String
Dim title As String = "Select a body"
Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
Dim response As Integer
Dim obj As NXOpen.Tag
Dim view As NXOpen.Tag
Dim cursor(2) As Double
Dim ip As UFUi.SelInitFnT = AddressOf mask_for_bodies
ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
Try
ufs.Ui.SelectWithSingleDialog(message, title, scope, ip, _
Nothing, response, body, cursor, view)
Finally
ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
End Try
'ufs.Disp.SetHighlight(body, 0)
If response <> UFConstants.UF_UI_OBJECT_SELECTED And _
response <> UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME Then
Return Selection.Response.Cancel
Else
Return Selection.Response.Ok
End If
End Function
Function mask_for_bodies(ByVal select_ As IntPtr, _
ByVal userdata As IntPtr) As Integer
Dim num_triples As Integer = 1
Dim mask_triples(0) As UFUi.Mask
mask_triples(0).object_type = UFConstants.UF_solid_type
mask_triples(0).object_subtype = UFConstants.UF_solid_body_subtype
mask_triples(0).solid_type = UFConstants.UF_UI_SEL_FEATURE_BODY
ufs.Ui.SetSelMask(select_, _
UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, _
num_triples, mask_triples)
Return UFConstants.UF_UI_SEL_SUCCESS
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY
End Function
End Module
THANKS in advanced
In this journal (that I revised from internet one) I get error in line 31
line 31 ==> attrInfo = body_object.GetUserAttribute("test",NXObject.AttributeType.String,-1)
Using NX8.5
What's wrong here
My goal is to read the body attribute (Title = Value) for a given title gets its value
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.UF
Module report_attrs_by_title_and_type
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Sub Main()
Dim body As NXOpen.Tag
While select_a_body(body) = Selection.Response.Ok
Dim loopVar As Integer = 0
Dim body_object As NXObject = CType(NXObjectManager.Get(body), NXObject)
MsgBox("Body Object:" & body_object.ToString())
Dim attrInfo As NXObject.AttributeInformation
Try
attrInfo = body_object.GetUserAttribute("test",NXObject.AttributeType.String,-1)
ufs.Ui.OpenListingWindow()
ufs.Ui.WriteListingWindow("Attribute Title: " & attrInfo.Title & vbCrLf)
ufs.Ui.WriteListingWindow("Attribute Type: " & attrInfo.Type.ToString & vbCrLf)
ufs.Ui.WriteListingWindow("Attribute StringValue: " & attrInfo.StringValue & vbCrLf)
Catch ex As Exception
MsgBox(ex.ToString(), MsgBoxStyle.Critical)
End Try
End While
End Sub
Function select_a_body(ByRef body As NXOpen.Tag) As Selection.Response
Dim message As String
Dim title As String = "Select a body"
Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
Dim response As Integer
Dim obj As NXOpen.Tag
Dim view As NXOpen.Tag
Dim cursor(2) As Double
Dim ip As UFUi.SelInitFnT = AddressOf mask_for_bodies
ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
Try
ufs.Ui.SelectWithSingleDialog(message, title, scope, ip, _
Nothing, response, body, cursor, view)
Finally
ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
End Try
'ufs.Disp.SetHighlight(body, 0)
If response <> UFConstants.UF_UI_OBJECT_SELECTED And _
response <> UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME Then
Return Selection.Response.Cancel
Else
Return Selection.Response.Ok
End If
End Function
Function mask_for_bodies(ByVal select_ As IntPtr, _
ByVal userdata As IntPtr) As Integer
Dim num_triples As Integer = 1
Dim mask_triples(0) As UFUi.Mask
mask_triples(0).object_type = UFConstants.UF_solid_type
mask_triples(0).object_subtype = UFConstants.UF_solid_body_subtype
mask_triples(0).solid_type = UFConstants.UF_UI_SEL_FEATURE_BODY
ufs.Ui.SetSelMask(select_, _
UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, _
num_triples, mask_triples)
Return UFConstants.UF_UI_SEL_SUCCESS
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY
End Function
End Module
THANKS in advanced





RE: Help in Journal Error
What does the error message say?
www.nxjournaling.com
RE: Help in Journal Error
the err is attribute not found
see attached image
Thank you for this
RE: Help in Journal Error
www.nxjournaling.com
RE: Help in Journal Error
The part contain an extrude of a sketch rectangle
that I right click on it and in the opened dialog on attribute tab
I set Title to "test" and a string type value I set it to "t3"
so I have Title = "test" and its value = "t3"
and for select a body I selected the extruded rectangle
and that give this err
Thank you again
RE: Help in Journal Error
www.nxjournaling.com
RE: Help in Journal Error
You are right
I set the attribute with filter solid body and that works
thank you very much
Cowski if I want to do that for all the atributtes of that solid body
can you help what functions to use
Thank you a lot
RE: Help in Journal Error
www.nxjournaling.com
RE: Help in Journal Error
I get it
it is near to me and I didn't see it
Thank you for this whole help
RE: Help in Journal Error
Hi cowski
If you see this
My finished journal works very well but I need it in DLL, but when I compile I get this errors
using nx8.5 and this compiling command
========================================================================================================================
C:\WINDOWS\Microsoft.NET\Framework\v3.5\vbc /libpath:C:\hvv\_VBC\managed /t:library /r:NXOpen.dll /r:NXOpen.Utilities.dll /r:NXOpen.UF.dll /r:NXOpenUI.dll report_body_attribute_for_title_ref_des_value_13.vb > o3.txt
=========================================================================================================================
o3.txt output
Microsoft (R) Visual Basic Compiler version 9.0.30729.5420
Copyright (c) Microsoft Corporation. All rights reserved.
C:\haviv\dev\__UniGraphics_VB__\_VBC\report_body_attribute_for_title_ref_des_value_13.vb(32) : error BC30456: 'GetUserAttributes' is not a member of 'NXOpen.NXObject'.
attrInfo = body_object.GetUserAttributes()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\haviv\dev\__UniGraphics_VB__\_VBC\report_body_attribute_for_title_ref_des_value_13.vb(40) : error BC30456: 'StringValue' is not a member of 'NXOpen.NXObject.AttributeInformation'.
def_res_value = attrInfo(loopVar).StringValue
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\haviv\dev\__UniGraphics_VB__\_VBC\report_body_attribute_for_title_ref_des_value_13.vb(45) : error BC30456: 'StringValue' is not a member of 'NXOpen.NXObject.AttributeInformation'.
geom_name_value = attrInfo(loopVar).StringValue
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\haviv\dev\__UniGraphics_VB__\_VBC\report_body_attribute_for_title_ref_des_value_13.vb(76) : warning BC42024: Unused local variable: 'obj'.
Dim obj As NXOpen.Tag
~~~
C:\haviv\dev\__UniGraphics_VB__\_VBC\report_body_attribute_for_title_ref_des_value_13.vb(84) : warning BC42104: Variable 'message' is used before it has been assigned a value. A null reference exception could result at runtime.
ufs.Ui.SelectWithSingleDialog(message, title, scope, ip, _
=============================================================================================================================
journal code
======================
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Utilities
Imports NXOpen.UF
Module report_body_attribute_for_title_ref_des_value
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Sub Main()
Dim body As NXOpen.Tag
Dim def_res_title As String
Dim geom_name_title As String
Dim def_res_value As String
Dim geom_name_value As String
While select_a_body(body) = Selection.Response.Ok
Dim loopVar As Integer = 0
Dim body_object As NXObject = CType(NXObjectManager.Get(body), NXObject)
Dim attrInfo() As NXObject.AttributeInformation
Try
attrInfo = body_object.GetUserAttributes()
Dim cntr As Integer = attrInfo.Length - 1
Do While loopVar <= cntr
If attrInfo(loopVar).Title = "REF_DES" Then
def_res_title = attrInfo(loopVar).Title
def_res_value = attrInfo(loopVar).StringValue
End If
If attrInfo(loopVar).Title = "GEOM_NAME" Then
geom_name_title = attrInfo(loopVar).Title
geom_name_value = attrInfo(loopVar).StringValue
End If
loopVar = loopVar + 1
Loop
theUI.NXMessageBox.Show("logo name" , _
NXMessageBox.DialogType.Information, _
def_res_title & " = " & def_res_value & vbCrLf _
& vbCrLf & geom_name_title & " = " & geom_name_value)
def_res_value = ""
geom_name_value = ""
def_res_title = ""
geom_name_title = ""
ufs.Disp.SetHighlight(body, 0)
Catch ex As Exception
MsgBox(ex.ToString(), MsgBoxStyle.Critical)
End Try
End While
End Sub
Function select_a_body(ByRef body As NXOpen.Tag) As Selection.Response
Dim message As String
Dim title As String = "Select a body"
Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
Dim response As Integer
Dim obj As NXOpen.Tag
Dim view As NXOpen.Tag
Dim cursor(2) As Double
Dim ip As UFUi.SelInitFnT = AddressOf mask_for_bodies
ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
Try
ufs.Ui.SelectWithSingleDialog(message, title, scope, ip, _
Nothing, response, body, cursor, view)
Finally
ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
End Try
'ufs.Disp.SetHighlight(body, 0) this line here
'give error so I moved it to main sub
If response <> UFConstants.UF_UI_OBJECT_SELECTED And _
response <> UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME Then
Return Selection.Response.Cancel
Else
Return Selection.Response.Ok
End If
End Function
Function mask_for_bodies(ByVal select_ As IntPtr, _
ByVal userdata As IntPtr) As Integer
Dim num_triples As Integer = 1
Dim mask_triples(0) As UFUi.Mask
mask_triples(0).object_type = UFConstants.UF_solid_type
mask_triples(0).object_subtype = UFConstants.UF_solid_body_subtype
mask_triples(0).solid_type = UFConstants.UF_UI_SEL_FEATURE_BODY
ufs.Ui.SetSelMask(select_, _
UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, _
num_triples, mask_triples)
Return UFConstants.UF_UI_SEL_SUCCESS
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY
End Function
End Module
=======================================================================================================================
I see a lot about this error in the internet
but I found nothing that can help
Thank you in advanced
RE: Help in Journal Error
If so, make sure that the compiler is referencing the NX 8.5 dll files and not the older versions.
www.nxjournaling.com
RE: Help in Journal Error
Without your help I'll never never come to it
The internet not helped me you do
Thank you very very much
RE: Help in Journal Error
www.nxjournaling.com