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?
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
Best regards
Simon NX7.5.4.4 MP8 - TC 8 www.jcb.com
RE: Curve along a cylinder
Please find the DXF drawings attached.
The txt file is the center positions of the pin which moves along the curve slot.
RE: Curve along a cylinder
RE: Curve along a cylinder
Cheers
Si
Best regards
Simon NX7.5.4.4 MP8 - TC 8 www.jcb.com
RE: Curve along a cylinder
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 ModuleFrank Swinkels
RE: Curve along a cylinder
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
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
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
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
see error message I got.
RE: Curve along a cylinder
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
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
This model will be more difficult to build.
RE: Curve along a cylinder
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
RE: Curve along a cylinder
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
Let me know what you think.
Frank Swinkels
RE: Curve along a cylinder
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
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
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
Frank Swinkels
RE: Curve along a cylinder
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
RE: Curve along a cylinder
This is the curve that you are wrapping. If that curve is this .... then the wrapped curve will be ....
- Clean the input data / curve.
Regards,
Tomas
RE: Curve along a cylinder
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
I dont understand the latest data?
Frank Swinkels
RE: Curve along a cylinder
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
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
RE: Curve along a cylinder
X = column 1
Y=(121.5/2)*Cos(column 3)+column 2
Z=(121.5/2)*Sin(column 3)
and created points in the attached part. You should be able to see that the points do not wrap around a cylinder.
That is the data cannot be used directly.
Frank Swinkels
RE: Curve along a cylinder
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
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