Cancel
Showing results for 
Search instead for 
Did you mean: 

How to get start point of each patterned instance

Valued Contributor
Valued Contributor

Hello,

On the attached image bellow is an single line which is perpendicular to the pathe curve. That line is patterned along the curve.

img02.PNG

I am wondering if someone could give me idea how to get the start (fixed) point of each instance. I can do by creating intesection points between curve and each instance but problem happened when I try to sort the coords of the points by x or y value. Points are getting mixed. Coordinates of the points must be arranged by the instance order.

 

Any idea is gladly appreciated!

Danijel

21 REPLIES 21

Re: How to get start point of each patterned instance

Can you get a point on curve percentage on each of the instances? If the directions are mixed, you might have to create 0 and 100 percent, and ask which one is closer to the parent curve.

 

Alternatively, you could use the distance by arc length to sort your intersection points. Just ask for distance to 0 percent point of the parent curve.

        length, curves = theSession.Measurement.GetArcLengthBetweenPoints(p1, p2)
Nikolas Losse | Developer | Siemens PG PR R&D TEC
NX12 | CentOS7 | Python

Re: How to get start point of each patterned instance

Valued Contributor
Valued Contributor

Hello @NikolasLosse,

I have used this option to pattern the line.

img03.PNG

 

Re: How to get start point of each patterned instance

But then you can even calculate the arc length percentages your intersection points are at!

 

If you use workPart.Points.CreatePoint()  (workPart.Points is a NXOpen.PointCollection)

with this signature

 

   Signature CreatePoint(edgeCurve, scalarT, locationOption, updateOption) 

   Creates a NXOpen.Point on a NXOpen.Curve or NXOpen.Edge and NXOpen.Scalar representing the Percent    parameter or Arc Length or Percent Arc Length.

 

 

Nikolas Losse | Developer | Siemens PG PR R&D TEC
NX12 | CentOS7 | Python

Re: How to get start point of each patterned instance

Valued Contributor
Valued Contributor

Nikolas,

I am not familiar with Python programming. I use VB.Net (VS2015) and search for the functions that you provided.

In the meaning time, I have used PointSet option to create points on curve (path used for pattern before) by equal arc length but the results are not what I expected.

img07.PNG

Compare created points and start points of the instances are showed on the image bellow.

img06.PNG

Re: How to get start point of each patterned instance

Hmm, that could either be a tolerance thing, or a display thing. Are they still different points if you set the display resolution to high in the Visualization Preferences?

 

If they really are different, I'd suggest creating the 0-percent points for each child curve.

 

The function names are usually the same. I just found out that the .NET reference is not available online. Weird. I'd look for the PointCollection.CreatePoint function.

Nikolas Losse | Developer | Siemens PG PR R&D TEC
NX12 | CentOS7 | Python

Re: How to get start point of each patterned instance

Valued Contributor
Valued Contributor

Menu > Preferences > Visualization > Faceting (tab) where Resolution is set to UltraFine but still the same.

 

Re: How to get start point of each patterned instance

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Try running the following journal. Note that it assumes the objects that were patterned are lines (as shown in your screenshot), other objects may give errors or odd results.

 

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module2

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()

    Dim theUI As UI = UI.GetUI()
    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        Dim workPart As Part = theSession.Parts.Work
        Dim myPatternGeo As Features.PatternGeometry = Nothing
        Dim found As Boolean = False

        For Each temp As Features.Feature In workPart.Features
            If TypeOf (temp) Is Features.PatternGeometry Then
                myPatternGeo = temp
                found = True
                Exit For
            End If
        Next

        If Not found Then
            lw.WriteLine("no pattern geometry feature found")
            Return
        End If

        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

        lw.Open()

        Dim patternedObjs() As DisplayableObject
        patternedObjs = myPatternGeo.GetAssociatedCurvesPointsDatums

        lw.WriteLine("number of patterned objects: " & patternedObjs.Length.ToString)
        lw.WriteLine("start points of patterned lines")

        For Each temp As Line In patternedObjs
            lw.WriteLine(temp.StartPoint.ToString)
        Next

        lw.Close()

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module

Re: How to get start point of each patterned instance

Valued Contributor
Valued Contributor

Hi @cowski1,

This works great and there should not be a problem cause the object that I would like to pattern is always a single line.

There is one more thing that I would like to achieve. On the attached video you will see why I needed start point of each instance line. After instances are trimmed with some studio spline, I wanted to use start/end point to get midpoint of each trimmed curve. I have done it by using coordinates of start/end points for each trimmed curve.

        Dim midPointX, midPointY As Double
        midPointX = (startPointX + endPointX) / 2
        midPointY = (startPointY + endPointY) / 2

I believe there is some easier way by using NX functions.

(view in My Videos)

 

Re: How to get start point of each patterned instance

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

If you need to create a point that is associative to the midpoint of the line, the .CreatePoint method has some options for that. If all you need are the unassociative coordinates of the midpoint for a given line, what you have is probably as easy as it gets.