NXOpen GetLength Curve Length Collection | For and Next curve in Nx Siemens

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • NXOpen GetLength Curve Length Collection | For and Next curve in Nx Siemens
    NX can create parts and assemblies with complex geometry and product structure. Sometimes you will need to
    perform operations on a collection of objects in your parts or assemblies. Using a journal to cycle through a
    collection will often make these tasks easier. We will start by creating some simple journals to understand how to
    cycle though object collections.
    This is a repetitive "loop" process. The statements between the
    "For" statement and the "Next curve" statement are executed for
    each curve in workPart.Curves, which is the CurveCollection of
    the work part.
    For Each curve In workPart.Curves
    the body of our loop
    Next curve
    Get the length of the curve by calling the GetLength method on
    the curve.
    curveLength = curve.GetLength()
    Output a line of text to the information window. The "&"
    character takes two strings and combines them into one. The
    Integer variable "numCurves" is converted to a string before it is
    combined with the other strings.
    Guide.InfoWriteLine
    ("Work part has " & numCurves & " curves.")
    -----------------------------------------------------------------
    Code:
    Imports NXOpen
    Module NXOpenSample
    Sub Main ()
    Dim theSession = Session.GetSession()
    Dim workPart = theSession.Parts.Work
    Dim numCurves As Integer = 0
    Dim curveLength As Double
    For Each cur As curve In workPart.Curves
    numCurves = numCurves + 1
    curveLength = cur.GetLength
    Guide.InfoWriteLine("Curve " & numCurves & " has length " & curveLength)
    Next cur
    Guide.InfoWriteLine("Work part has " & numCurves & " curves.")
    End Sub
    End Module
    ----------------------------------------------

Комментарии •