×
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

Curve along a cylinder

Curve along a cylinder

Curve along a cylinder

(OP)
The center points of the cutting tools(pin) are given in X and A (rotation axis)
The cutter diameter (pin) is constant, e.g. 40mm.
The pin goes around the cylinder for one turn (360 degree) or more to generate a curve slot.
The points are given in a txt file (thousands of points)
I can import the points as a spline.
How can I warp the points on the cylinder?
Slot: How to sweep a cylinder with 40mm diameter along the curve? After the sweep is generated, subtract it from the cylinder to create the model with the slot?

RE: Curve along a cylinder

It is quite difficult to understand exactly what you are trying to do?, also, what version of NX are you running?

Best regards

Simon NX7.5.4.4 MP8 - TC 8 www.jcb.com

RE: Curve along a cylinder

Below is a journal that creates the spline as I interpret the data. I used the first number as distance along the x-axis and the second number is the angle around the cylinder. Therefore the y value is radius*cos(angle) and the z value is radius*sin(angle). Please note the journal will only work on NX8.

CODE -->

Option Strict Off
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Features

Module cylinderCurve

    Dim s As Session = Session.GetSession()
    Dim workPart As Part = s.Parts.Work

    Sub Main()
        Try
            Dim pointsFile As String
            Dim testArray() As String
            'open txt file
            Dim fdlg As OpenFileDialog = New OpenFileDialog()
            fdlg.Title = "Choose the points file"
            fdlg.InitialDirectory = "c:\"
            fdlg.Filter = "All files (*.*)|*.*|TXT files (*.txt)|*.txt"
            fdlg.FilterIndex = 2
            fdlg.RestoreDirectory = True
            If fdlg.ShowDialog() = DialogResult.OK Then
                pointsFile = fdlg.FileName
            End If
            If fdlg.ShowDialog() = DialogResult.OK Then
                Dim sr As StreamReader = New StreamReader(fdlg.FileName)
                Dim linestring As String
                Dim number1 As Double = Nothing
                Dim number2 As Double = Nothing
                Dim pnt(2) As Double
                Dim coordinates1 As Point3d
                Dim ArrayOfPoints(-1) As Point
                Dim cnt1 As Integer = 0
                Dim deg2rad As Double = Math.PI / 180.0
                Dim rad1 As Double = 20.0
                Try
                    Do While sr.Peek >= 0
                        linestring = sr.ReadLine
                        testArray = Split(linestring, vbTab, 2)
                        number1 = CDbl(testArray(0))
                        number2 = CDbl(testArray(1))
                        pnt(0) = number1
                        pnt(1) = rad1 * Math.Cos(number2 * deg2rad)
                        pnt(2) = rad1 * Math.Sin(number2 * deg2rad)
                        coordinates1 = New Point3d(pnt(0), pnt(1), pnt(2))
                        ReDim Preserve ArrayOfPoints(cnt1)
                        ArrayOfPoints(cnt1) = workPart.Points.CreatePoint(coordinates1)
                        cnt1 += 1
                    Loop
                    CreateStudioSplineThruPoints(ArrayOfPoints)
                Finally
                    sr.Close()
                End Try
            End If
        Catch E As Exception
            MessageBox.Show(E.Message)
            Exit Sub
        End Try
    End Sub

    Public Sub CreateStudioSplineThruPoints(ByRef points() As Point)
        Dim markId9 As Session.UndoMarkId
        markId9 = s.SetUndoMark(Session.MarkVisibility.Visible, "Studio Spline Thru Point")
        Dim Pcount As Integer = points.Length - 1
        Dim nullNXObject As NXObject = Nothing
        Dim studioSplineBuilderEx1 As Features.StudioSplineBuilderEx
        studioSplineBuilderEx1 = workPart.Features.CreateStudioSplineBuilderEx(nullNXObject)
        studioSplineBuilderEx1.Degree = 3
        studioSplineBuilderEx1.InputCurveOption = StudioSplineBuilderEx.InputCurveOptions.Delete
        studioSplineBuilderEx1.Type = Features.StudioSplineBuilderEx.Types.ThroughPoints
        studioSplineBuilderEx1.IsPeriodic = False
        studioSplineBuilderEx1.MatchKnotsType = Features.StudioSplineBuilderEx.MatchKnotsTypes.None
        studioSplineBuilderEx1.HasPlaneConstraint = False
        studioSplineBuilderEx1.OrientExpress.AxisOption = GeometricUtilities.OrientXpressBuilder.Axis.Passive
        studioSplineBuilderEx1.OrientExpress.PlaneOption = GeometricUtilities.OrientXpressBuilder.Plane.Passive
        Dim knots1(-1) As Double
        studioSplineBuilderEx1.SetKnots(knots1)
        Dim parameters1(-1) As Double
        studioSplineBuilderEx1.SetParameters(parameters1)
        Dim nullDirection As Direction = Nothing
        Dim nullScalar As Scalar = Nothing
        Dim nullOffset As Offset = Nothing
        Dim geometricConstraintData(Pcount) As Features.GeometricConstraintData
        For ii As Integer = 0 To Pcount
            geometricConstraintData(ii) = studioSplineBuilderEx1.ConstraintManager.CreateGeometricConstraintData()
            geometricConstraintData(ii).Point = points(ii)
            geometricConstraintData(ii).AutomaticConstraintDirection = Features.GeometricConstraintData.ParameterDirection.Iso
            geometricConstraintData(ii).AutomaticConstraintType = Features.GeometricConstraintData.AutoConstraintType.None
            geometricConstraintData(ii).TangentDirection = nullDirection
            geometricConstraintData(ii).TangentMagnitude = nullScalar
            geometricConstraintData(ii).Curvature = nullOffset
            geometricConstraintData(ii).CurvatureDerivative = nullOffset
            geometricConstraintData(ii).HasSymmetricModelingConstraint = False
        Next ii
        studioSplineBuilderEx1.ConstraintManager.SetContents(geometricConstraintData)
        Dim feature1 As Features.Feature
        feature1 = studioSplineBuilderEx1.CommitFeature()
        studioSplineBuilderEx1.Destroy()
    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module 


Frank Swinkels

RE: Curve along a cylinder

(OP)
Thank you so much, JCBCAD,
The original points were given in (X, A). I added one more column as Z value. I also change the file extension from TXT to DAT. It can be imported into NX as spline now. Can you please help me to take a look at the curve file again?
The 40mm slot (two-side curve walls as target) is generated by a cylinder with diameter 40mm which goes along the curve. It is a little different from what you did.
If a 40mm cylinder (solid) could be built based on each point of the curve (sweep along the curve), subtract the sweep, it will be more exactly. But NX does not supply solid model sweep.
Could you please help to take a look at it one more time? Thanks

Thank you FrankSwinks,
I imported your journal. It works OK.
The curve can be imported as a spline. But the shape looks quite differently. Please find the file attached, called “journal_curve_imported”
The original coordinate is given in (X, A)
I modified the coordinate file into (X, Y, Z) format
X=the original X in the original file
Y=(506/2)*Cos(A)
Z=(506/2)*Sin(A)
I imported the new coordinates, the curve looks very differently again.
Can you please help to take a look at it? Thanks

RE: Curve along a cylinder

Frank, it might better to layout the spline as a flat curve and then wrap it around a cylinder.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.

RE: Curve along a cylinder

OK to create the spline around a cylinder of 506 diameter just change one line in the journal from

Dim rad1 As Double = 20.0

to

Dim rad1 As Double = 253.0

I have attached the small modification as a .txt file. Just change the extension back to .vb to use as a NX8 journal.

To create the spline around a cylinder of any size, position and orientation I could add some code to have you select a cylinder and the data file. If this is required I suggest we first have a correct spline in the default position with the cylinder origin at 0,0,0 and the cylinder axis along the X axis.

Frank Swinkels

RE: Curve along a cylinder

(OP)
It’s wonderful, Frank.
I used the original txt file, coordinates in (X, A) file. The curve has been imported successfully. It looks very good.
I also inserted a cylinder. The splines wraps automatically on the cylinder.
My question:
How to make a cylindrical pin (hole) along the curve? On this case, the pin diameter is 40mm.
Theoretically, the number of the pin holes will be the same as the number of the points from the coordinate file.
This is in (X, A)version, the Y stays still. So the cylindrical pin centre line goes through the centre line of the cylinder and also is perpendicular to the X-Y plane.
Could you please help with one more step further? Thanks.

RE: Curve along a cylinder

Attached is a NX8 part file in which I have created the slot as I think you described it. I extended the original journal to create two further splines (the blue splines on layer 2). I then (manually) added a U spline for the groove section. Finally I created a swept sheet body and trimmed the cylinder. The definition of the two blue splines is somewhat complex but points on the blue spline is defined as follows. At a point on the centre spline I use the spline tangent vector and the cylinder face normal. Taking the cross product of these two vectors gives us a vector in the direction of a point on each of the blue splines. I also needed to move away from the cylinder face (using the normal) to ensure we are external to the cylinder face.

Now some limitations. The blue splines must be closed splines. Therefore the data should be limited to 360 degrees. Next your data points have a region where the path radius of curvature is less than the groove half width. This will normally result in a self intersecting spline. What I did for this example is to reduce the number of spline points so that I did not get a self intersecting spline. Now it is possible to overcome this but again it adds complexity to the program. At the same time it seems to me that if this is to operate as a cam you are getting a jerk condition which for most mechanisms is undesirable.

Anyway let me know what you think and I will see what I can do with the journal.

Frank Swinkels

RE: Curve along a cylinder

(OP)
Thank you, Frank
It works ok. But still not exactly what I wish.
I wish to import splines from TXT file. The TXT file coordinates can be (X, A) and can also be (X, Y, A) sometimes.
After the txt file is imported and a spline is generated, I want to insert a pin (a cylinder pin for the most of cases, sometimes a tapered pin) and the pin will sweep along the curve according to the positions given in the txt file (same as tool path).
The reason that I want to have a cylinder pin instead of straight line is that the engagement point of the both sides of the pin against the cylinder can be some different from the straight line. Also the two curves of the two side-wall can also be different because the engagement points can be different if Y-axis is engaged.
After the sweep is generated, I would like subtract the sweep from the cylinder. I wish my explanation is clear.

RE: Curve along a cylinder

Attached is the same part file with some 200 circles placed 10 mm down into the slot (to represent a section of the pin). You can measure the distance from the circle centre to the slot side wall and you will find that it is within modeling tolerance. I used 0.025 mm tolerance and all values are typically within 0.004 with the exception in the small region when the path curvature is less than the "pin" radius. As I mentioned before this can be modelled more acurately but takes considerable more programming. The modelling tolerance can be tighted. For demo purposes I cannot see any advantage for doing that.

What I am saying is that I believe the slot is accurate (within modelling tolerance and noting the exception) and that this is the only way of achieving what you're after. I don't believe you can trace a solid (the pin) to obtain the slot.

By the way I cannot extract anything from a rar file.

Frank Swinkels

RE: Curve along a cylinder

(OP)
Smoothness of the curve
I think that this cam has some problem in their original design. The curve is not smooth enough. Please find the photo attached.
Can the curve be smoothed? Can a pin be inserted into the slot and have the jerk analysed, in order to let the pin run smoothly in the slot?

RE: Curve along a cylinder

Attached is a part in which I have created a planar curve based on your file. I use the first and last four points and then at every 5 degrees. I then wrapped the spline around the face. You will note that even with point spacing we still get a wriggle at one point in the spline. If this is good enough fine. If it is not good enough I suggest you should look at your data.

Let me know what you think.

Frank Swinkels

RE: Curve along a cylinder

(OP)
Hi Frank
Step 1: Prepare the txt file into DAT file
This is how I did without your journal
The original coordinate file was txt file in (X, A).
I added one more column for Z value. I put constant value 0 for all Z.
I changed the format into DAT file because standard NX only allows me to import DAT format.

Step 2: import the DAT file as spline: Insert>Curve>Spline>Through Points>Multiple Segments and leave the curve degree 3 and select Points from File
The spline will then be imported.

Step 3: Draw a Basic curve to the spline
Step 4: Insert a Law Curve. I used the Expression method:
X=XT=r*COS(A)
Y=YT=r*Sin(A)
Z=Use Law Curve
Then the curve will be showed and called Law-Defined Spline

Step 4: Offset the curve to create two offset curves (I used 3D Axial and offset by giving distance 20mm. (Not sure whether the offset is the correct way in building the model)
Can you please check the difference between the models using law curve and your journal?

Step 4: I created the swept.
Step 5: subtract the swept!! Not Successfully to subtract the swept from the body!!!

One thing is absolutely sure that using your journal is much better way, much easier and faster.
But what can I do if the coordinates are given in (X, Y, A)

RE: Curve along a cylinder

Regarding second step 4

Step 4: Offset the curve to create two offset curves (I used 3D Axial and offset by giving distance 20mm. (Not sure whether the offset is the correct way in building the model)

This is not correct. The reason is that the 3D Axial direction for offset is only correct for points on the spline when the wrapped spline is at 90 degrees to the cylinder axis. At any other angle the offset must be determined using the the wrapped spline tangent and the cylinder face normal at the point of interest (taking the cross product to get the offset direction. I think the only way to do this is with a journal


Step 4: I created the swept.

The swept body will not subtract correctly in your case for two reasons. One is that your two splines need to be closed (periodic). The second reason is that based on what you indicated above I think you swept body limits pass in and out of the cylinder face.

Did you look at the part I sent previously? It generates a planar spline from the data. I then, still as a journal, wrap the spline around the cylinder. Before I do more work on the journal I need to know if this good enough in terms of the what I believe is data limitations. Just to let you see the results included is a further part file.

Please look at it and let me know if this is accurate enough before I can any further work on a journal.

Frank Swinkels

RE: Curve along a cylinder

(OP)
Thank you, Frank
With your journal, I can import the splines directly from the original txt file. A cylinder can be inserted in. the splines will be wrapped on the cylinder very well.
I have been struggling in doing the offsetting the curve in order to create the slot. Can you please tell me how to do the offsetting? Do I have to manually modify the original txt file in order to run the journal again to create the two side curves?

RE: Curve along a cylinder

I appear not be able to clearly explain where I am coming from. Let me try again. The current journal you have cannot be used in any way to create the additional splines. YES I do have a journal that creates a planar spline. The spline is then wrapped around a cylinder and the two additional splines are created. The reason I have not made it available is because you had a concern about the quality of the spline (in one region). I have sent you a part file and needed you to determine if the splines created are good enough. If not I believe the data should be improved. Please respond to this question. If you choose not to respond to this I can be of no further help.

Frank Swinkels

RE: Curve along a cylinder

(OP)
Thank you, Frank. I believe that your method is exactly what I am looking for.
At the same time, I am also asking the cam designer to provide me more accurate points, especially for X-axis coordinates. The decimal places for X-axis in the original txt file don’t look enough. The angle value looks OK.

RE: Curve along a cylinder

(OP)
Thank you Frank & Toost, Could you please take a look at this file attached? The quality of the curve is very good. i don't worry about the smoothness of the curve.

The reference diameter is 121.5mm
The Pin diameter is 40mm

I believe that X will be still A from the table
Y=(121.5/2)*Cos(A)+(Y value from the table)
Z=(121.5/2)*Sin(A)

Not sure exactly what I think is correct. Thank you again for your help.

RE: Curve along a cylinder

Attached is a .txt file (change .txt to .vb) for a journal to test against original data. The journal completes the full process i.e. create planar curve -> wrapped curve -> offset curves -> sweep feature -> boolean subtract. To improve the data I I used four point 0 -> 0.4, then every 10 degrees and finally four points from 359.7 to 360.0. The reason for the first and final four points is to ensure good direction control for the wrapped curve. I have only used some 35 intermidiate points. This is quite a good curve for the initial planar curve. Wrapping it adds points on the cylinder face. I really think that the whole method should be rethought. You really only need at a maximum seven points for each cam section (dwell, rise and fall). Also using math equations even cycloidal equations, ensures high accuracy.

I dont understand the latest data?

Frank Swinkels

RE: Curve along a cylinder

The last question, ?
You attached a zipfile containing a dxf and two textfiles. The DXF translates into something completely unusable ( See attached image)
The highlighted spline has 3138 poles (!) and even without checking the smoothness, i would say "no, it cannot be smooth because it is completely overloaded with data", Too much data doesn't make things better, rather the opposite. For example, If we would try to fit an arc to three points we would find an exact solution, But if we would try fit the same arc to 3138 points we would very soon have tolerance problems .( or decimal problems. )
In this case we expect the points to be exact and then we fit a spline, which can have any possible shape, to ALL these points. The result is of course non-smooth since the points "cannot" be exact enough. The result can be smooth if we use some kind of algorithm that tries to reduce the amount of data ( which will make the curve smoother) and allows a deviation to the points. This is exactly what the Fit Spline in NX does.
Also, one should not attempt to create a single spline that encompasses the entire distance, again one will have to fight the data mass problem trying to make the spline linear in one section whilst trying to find the correct shape in the next section. dxf example is better, divide different shapes into separate curves, then each curve can be as simple as possible.

Regards,
Tomas

RE: Curve along a cylinder

I don't have translators so cannot comment on dxf however the data file is not workable because I don't know the meaning of

T 40.0000 1 69.0000 18.5000 .0000 -31.5000 -70.0000
82.0000 .0000

also the points data values start of as three values e.g.

89.4327422 -11.9672732 .0000000

but change to two values (actually three but no space between second and third)

89.4805296 -12.0150176-100.0000000

This makes it very difficult to read the data. Not impossible but I am not prepared to do this when it appears to me a total lack of care.

Regarding the comments about the number of spline points I have not seen any comments about the last complete program that uses many less points and creates the groove.

Frank Swinkels

RE: Curve along a cylinder

(OP)
I have had a talk with a math professor.

He said

X = column 1
Y=(Reference diameter/2)*Cos(column 3)
Z=(Reference diameter/2)*Sin(column 3)

Y value in the column 2 should be the machine movement value in Y-axis.
When building the model, the column 2 should not be considered at this stage.

RE: Curve along a cylinder

Attached are two further examples based on the the latest data. Which method is correct?

To be able to supply a journal you still need to supply much more consistant data files.

1) The first data had two columns. The second two data files had three columns.

2) The first data file could be read with delimiter. The second two I had to use fixed format.

3) As mentioned by Toots and myself it is very poor design to create splines with so many points since good design suggest we first create a planar curve which is then wrapped around the cylinder. Therefore we only need a maximum of seven points for each of the cam motions (dwell, rise, dwell, return) for the planar spline. The wrapped spline will have sufficient spline points according to the accuracy required.

Without these issues addressed I am not prepared to supply a journal because I am sure you will get errors most times.

Frank Swinkels

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