Code read UFWeight.StateType (vb)
Code read UFWeight.StateType (vb)
(OP)
Hi,
i want to read the current "Weight Status" of the present File in NX with VB.Net.
Checling it manually, go to the Assembly-Navigator add the Column Weight Status and check the green Hook or yellow "?".
Some lines of Code:
if UFWeight.StateType.unknown = 3 then
' ...
end if
This Code will check if the Status "?" unknown is than 3.
Some more information can be read here:
https://docs.plm.automation.siemens.com/data_servi...
Can someone support me in some lines Code, how to read the actual Status of weight (UFWeight.StateType = ... value).
Thanky a lot.
Kind regards, Frank
i want to read the current "Weight Status" of the present File in NX with VB.Net.
Checling it manually, go to the Assembly-Navigator add the Column Weight Status and check the green Hook or yellow "?".
Some lines of Code:
if UFWeight.StateType.unknown = 3 then
' ...
end if
This Code will check if the Status "?" unknown is than 3.
Some more information can be read here:
https://docs.plm.automation.siemens.com/data_servi...
Can someone support me in some lines Code, how to read the actual Status of weight (UFWeight.StateType = ... value).
Thanky a lot.
Kind regards, Frank





RE: Code read UFWeight.StateType (vb)
Unfortunatly I don't have the answer
But I would like to add another question:
How to retrieve the assembly weight to place it in the parts list ?
Regards
Didier Psaltopoulos
http://www.psi-cad.fr
RE: Code read UFWeight.StateType (vb)
You can extract the active partfile or assembly's weight(mass) by using this function:
ufs.Weight.EstabPartProps1 (pleas see net_ref.chm for further details.
Then if you run a custom program (automatic in background) every time you save, you can get the assembly weight into an attribute - which can be used in your partlist.
lklo
CODE -->
Dim wProps As NXOpen.UF.UFWeight.Properties = Nothing Dim wExcept() As NXOpen.UF.UFWeight.Exceptions = Nothing ' changed to array, so ufs.Weight.EstabPartProps1 can be used Dim weight_value As Double = 0CODE -->
Function FindPartWeight(ByVal part_to_calculate As part) Try ufs.Weight.EstabPartProps1(thePart.Tag, 0.9, True, UFWeight.UnitsType.UnitsGm, wProps, wExcept) weight_value = (Format((wProps.mass) / 1000, "0.0000")) Return weight_value Catch e As Exception 'nx("Failed: " & e.ToString) Return weight_value End Try End FunctionRE: Code read UFWeight.StateType (vb)
Thanks à lot
Regards
Didier Psaltopoulos
http://www.psi-cad.fr
RE: Code read UFWeight.StateType (vb)
unfortunatelly my Thread was used for a second Question and my One was not answered jet
So, i want to ask again:
I want to read the current "Weight Status" of the Workpart in NX with VB.Net.
Checking it manually: Go to the Assembly-Navigator add the Column -Weight Status- and check the green Hook or yellow "?".
The Code should read out what sign is there (green Hook or what ever).
Some lines of Code:
if UFWeight.StateType.unknown = 3 then
' ...
end if
The "UFWeight.StateType.unknown" is defined as Status 3, that means the Sign "?".
But how can i read out this Information?
Can someone support me in some lines Code, how to read the actual Status of weight (UFWeight.StateType = ... value).
Thanky a lot.
Kind regards, Frank
RE: Code read UFWeight.StateType (vb)
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim theUfSession As UFSession = UFSession.GetUFSession Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim myWeightProps As UFWeight.Properties Dim myWeightExceptions() As UFWeight.Exceptions theUfSession.Weight.AskProps(workPart.Tag, UFWeight.UnitsType.UnitsLf, myWeightProps) lw.WriteLine("cache state: " & myWeightProps.cache_state.ToString) If myWeightProps.cache_state = UFWeight.StateType.NoCache Then 'calculate weight theUfSession.Weight.EstabPartProps1(workPart.Tag, 0.999, True, UFWeight.UnitsType.UnitsLf, myWeightProps, myWeightExceptions) End If lw.WriteLine("mass: " & myWeightProps.mass.ToString & " lbf") End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately End Function End Modulewww.nxjournaling.com