Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Curve along a cylinder

Status
Not open for further replies.

shanghongcao

Mechanical
Sep 27, 2012
30
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?
 
Replies continue below

Recommended for you

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
 
Your point file looks to be missing data so I can't use it. However I've attached a mode which may give you a few ideas or tips for the future. If you edit the expression named CURVE, you will se that you can control the groove pitch.

Cheers

Si



Best regards

Simon NX7.5.4.4 MP8 - TC 8 www.jcb.com
 
 http://files.engineering.com/getfile.aspx?folder=9dbc6845-9b78-4516-9322-14e1c39728be&file=groove_SJW.prt
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
 
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
 
 http://files.engineering.com/getfile.aspx?folder=4c636072-f45f-4435-887e-5ba1884fe354&file=60PCA2300010_Cam_Machining.rar
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.
 
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
 
 http://files.engineering.com/getfile.aspx?folder=b84dbeff-5d0f-4fd4-b35c-f67a14124fe0&file=cylinderCurve.txt
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.
 
 http://files.engineering.com/getfile.aspx?folder=de9bb402-accc-42a2-bdc0-40ecae1eb221&file=60PCA2300010.prt
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
 
 http://files.engineering.com/getfile.aspx?folder=60a8da63-443a-4fc9-806d-1fccd5066a13&file=grooveExampler.prt
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.
 
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
 
 http://files.engineering.com/getfile.aspx?folder=fb5ae241-b43f-425f-8de5-4e0293b97482&file=GrooveExample.zip
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?
 
 http://files.engineering.com/getfile.aspx?folder=4b53f213-175f-41aa-b763-8069466d7b97&file=Smoothness_of_curve.png
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
 
 http://files.engineering.com/getfile.aspx?folder=8ac9d573-cc2c-4abe-b3a8-3d44651f20b6&file=grooveExample2.prt
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)

 
 http://files.engineering.com/getfile.aspx?folder=4f2bb06f-d1c0-4e89-8b81-06f7d012a804&file=60PCA2300010_LawCurveExpression.prt
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
 
 http://files.engineering.com/getfile.aspx?folder=40423f3e-da77-4c2c-ab0e-d40f1d2e0ab6&file=grooveExample2.prt
Status
Not open for further replies.

Part and Inventory Search

Sponsor