×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Code read UFWeight.StateType (vb)

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

RE: Code read UFWeight.StateType (vb)

Hi Frank,

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)

Hi -
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 = 0 

CODE -->

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 Function 

RE: Code read UFWeight.StateType (vb)

(OP)
Hello again,

unfortunatelly my Thread was used for a second Question and my One was not answered jet wink
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)

Here's some code I have (VB) that reads or calculates the weight of the work part. You can pass in the tag of a component to read the component weight instead of the work part.

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 Module 

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close