Two poles of a spline sitting on top of each other
Two poles of a spline sitting on top of each other
(OP)
Hello,
This is an unusual problem and doesn't happen often. When importing curves from a DXF file, the straight lines get converted to "lines" and curved lines get converted to "splines". So far so good. However, sometimes the converted splines are degree 3 and yet when I double click the spline, I see only 3 poles (there should be 4 poles for a 3 degree spline). The listing in the Studio Spline dialog clearly shows 4 poles, so where is the 4th pole? As it turns out, it is hidden beneath one of the other poles, the reason being that the location is almost identical to that pole. Here is an example using the complete listing of Spline Analysis for the troublesome spline:
Information on spline # 1
Closure Status Open
Degree 3
Number of Poles 4
Number of Segments 1
Number of C0 Knots 0
Number of C1 Knots 0
Number of C2 Knots 0
Rational Status Polynomial
Defining Data None
Pole Number 1
Weight = 1.000000000
Coordinates XC = 153.962813699 X = 153.962813699
YC = 102.993465737 Y = 102.993465737
ZC = 0.000000000 Z = 0.000000000
Pole Number 2
Weight = 1.000000000
Coordinates XC = 154.008676533 X = 154.008676533
YC = 102.947602903 Y = 102.947602903
ZC = 0.000000000 Z = 0.000000000
Pole Number 3
Weight = 1.000000000
Coordinates XC = 154.047486569 X = 154.047486569
YC = 102.958199206 Y = 102.958199206
ZC = 0.000000000 Z = 0.000000000
Pole Number 4
Weight = 1.000000000
Coordinates XC = 154.047472097 X = 154.047472097
YC = 102.958195255 Y = 102.958195255
ZC = 0.000000000 Z = 0.000000000
Approximate rho 0.444361561216626
************************************************************
As you can see, the coordinates of pole 3 and pole 4 are almost identical. The difference is only 0.000014472 mm. However in most cases, this is fine for creating extruded features, but causes problems later when exporting the NX part to STEP.
Is there an automated way to "clean up" splines like these by deleting the extraneous poles?
This is an unusual problem and doesn't happen often. When importing curves from a DXF file, the straight lines get converted to "lines" and curved lines get converted to "splines". So far so good. However, sometimes the converted splines are degree 3 and yet when I double click the spline, I see only 3 poles (there should be 4 poles for a 3 degree spline). The listing in the Studio Spline dialog clearly shows 4 poles, so where is the 4th pole? As it turns out, it is hidden beneath one of the other poles, the reason being that the location is almost identical to that pole. Here is an example using the complete listing of Spline Analysis for the troublesome spline:
Information on spline # 1
Closure Status Open
Degree 3
Number of Poles 4
Number of Segments 1
Number of C0 Knots 0
Number of C1 Knots 0
Number of C2 Knots 0
Rational Status Polynomial
Defining Data None
Pole Number 1
Weight = 1.000000000
Coordinates XC = 153.962813699 X = 153.962813699
YC = 102.993465737 Y = 102.993465737
ZC = 0.000000000 Z = 0.000000000
Pole Number 2
Weight = 1.000000000
Coordinates XC = 154.008676533 X = 154.008676533
YC = 102.947602903 Y = 102.947602903
ZC = 0.000000000 Z = 0.000000000
Pole Number 3
Weight = 1.000000000
Coordinates XC = 154.047486569 X = 154.047486569
YC = 102.958199206 Y = 102.958199206
ZC = 0.000000000 Z = 0.000000000
Pole Number 4
Weight = 1.000000000
Coordinates XC = 154.047472097 X = 154.047472097
YC = 102.958195255 Y = 102.958195255
ZC = 0.000000000 Z = 0.000000000
Approximate rho 0.444361561216626
************************************************************
As you can see, the coordinates of pole 3 and pole 4 are almost identical. The difference is only 0.000014472 mm. However in most cases, this is fine for creating extruded features, but causes problems later when exporting the NX part to STEP.
Is there an automated way to "clean up" splines like these by deleting the extraneous poles?
NX9 Win8.1 64bit i7-3770K 16GB Quadro2000





RE: Two poles of a spline sitting on top of each other
You're probably going to require a Journal or GRIP/SNAP program to do what you're asking in regards to automating clean up.
Tim Flater
NX Designer
NX 9.0.2.5 Win7 Pro x64 SP1
Intel Xeon 2.53 GHz 6GB RAM
NVIDIA Quadro 4000 2GB
RE: Two poles of a spline sitting on top of each other
Tim Flater
NX Designer
NX 9.0.2.5 Win7 Pro x64 SP1
Intel Xeon 2.53 GHz 6GB RAM
NVIDIA Quadro 4000 2GB
RE: Two poles of a spline sitting on top of each other
The DXF/DWG wizard won't convert the curves to lines and arcs, but there is a tool in NX called Simplify Curve, which I think does the same thing. However, this will break all the splines up into smaller segments which changes the shape of the original curves and makes it more complicated.
Anyway thanks for clearing things up Tim, I'll see if it's possible to create a journal to do this task.
NX9 Win8.1 64bit i7-3770K 16GB Quadro2000
RE: Two poles of a spline sitting on top of each other
It might be worth it to Google for this, as AI to DXF is a common practice and many are having the same issues such as yourself (cleanup required in CAD). There may be some things you can do in AI prior to exporting that helps importing into NX go a bit more smoothly (no pun intended).
Tim Flater
NX Designer
NX 9.0.2.5 Win7 Pro x64 SP1
Intel Xeon 2.53 GHz 6GB RAM
NVIDIA Quadro 4000 2GB
RE: Two poles of a spline sitting on top of each other
CODE
'NXSplineCleanup v1.0 '--------------------- 'Use this journal to clean up splines imported from a DXF file. 'Sometimes, imported splines contain an additional pole very close to one of the endpoints causing problems especially when exporting to STEP. 'This journal will remove those poles which are extremely close to any other pole in the same spline. 'Any spline that is modified will be colored in order to easily inspect the modified splines. 'An undo is added in case the result is unsatisfactory. 'Works for NX 8.0 and above. 'Written by CNSZU November 2014. Option Strict Off Imports System Imports NXOpen Module NXJournal Dim numPoles As Integer Dim selObjects, selCurves, selLines, selSplines, modSplines, delPoles As Integer Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim displayPart As Part = theSession.Parts.Display Dim lw As ListingWindow = theSession.ListingWindow Dim mySelectedObjects As NXObject() Dim studioSplineBuilderEx1 As Features.StudioSplineBuilderEx Dim x, y, z, prevX, prevY, prevZ As Double Dim i As Integer Dim SplineIsDirty As Boolean Sub Main() 'USER OPTIONS '--------------------------------------------------------------------------------------------------------- Dim Dist As Double = 0.0001 ' 'If two or more poles are closer than this distance, only one will remain. '--------------------------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------------------------- Dim ColorCleanedSplines As boolean = True 'if you don't want to color cleaned splines, set to 'false' '--------------------------------------------------------------------------------------------------------- '--------------------------------------------------------------------------------------------------------- Dim CleanupColor As integer = 145 'the new color of the modified spline '--------------------------------------------------------------------------------------------------------- Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Select Objects") If SelectObjects("Select", mySelectedObjects) = Selection.Response.Ok Then selObjects = mySelectedObjects.Length For Each mySelObj As NXObject In mySelectedObjects If TypeOf mySelObj Is Line Then selLines += 1 End If If TypeOf mySelObj Is Spline Then SplineIsDirty = False selSplines += 1 studioSplineBuilderEx1 = workPart.Features.CreateStudioSplineBuilderEx(mySelObj) numPoles = studioSplineBuilderEx1.ConstraintManager.Length x = 0 y = 0 z = 0 prevX = 0 prevY = 0 prevZ = 0 i = 0 Do 'for every pole Dim GCD As Features.GeometricConstraintData GCD = studioSplineBuilderEx1.ConstraintManager.FindItem(i) x = GCD.Point.Coordinates.X y = GCD.Point.Coordinates.Y z = GCD.Point.Coordinates.Z If x > prevX - Dist And x < prevX + Dist And y > prevY - Dist And y < prevY + Dist And z > prevZ - Dist And z < prevZ + Dist Then SplineIsDirty = True If i = 1 Then DeletePole(studioSplineBuilderEx1, i) 'delete current pole i -=1 end if if i >1 Then DeletePole(studioSplineBuilderEx1, i - 1) 'delete previous pole i -=1 End If End If prevX = x prevY = y prevZ = z i += 1 Loop While i < numPoles studioSplineBuilderEx1.Commit() studioSplineBuilderEx1.Destroy() If SplineIsDirty = True Then modSplines += 1 'COLOR THE FIXED SPLINE if ColorCleanedSplines = true then Dim dispSpline As DisplayableObject dispSpline = mySelObj Dim displayModification1 As DisplayModification displayModification1 = theSession.DisplayManager.NewDisplayModification() displayModification1.NewColor = CleanupColor Dim objects1(0) As DisplayableObject objects1(0) = dispSpline displayModification1.Apply(objects1) displayModification1.Dispose() end if End If End If Next selCurves = selLines + selSplines lw.Open() lw.WriteLine("-----------------------") lw.WriteLine("NXSplineCleanup v1.0") lw.WriteLine("-----------------------") lw.WriteLine("Selected Objects: " & selObjects) lw.WriteLine("Selected Curves: " & selCurves) lw.WriteLine("Selected Lines: " & selLines) lw.WriteLine("Selected Splines: " & selSplines) lw.WriteLine("-----------------------") lw.WriteLine("Cleaned Up Splines: " & modSplines) lw.WriteLine("Deleted Poles: " & delPoles) lw.WriteLine("-----------------------") lw.WriteLine("Process Complete!") End If lw.Close() End Sub Sub DeletePole(instudioSplineBuilderEx1 As Features.StudioSplineBuilderEx, inIndex As Integer) Dim GCDtoDelete As Features.GeometricConstraintData GCDtoDelete = instudioSplineBuilderEx1.ConstraintManager.FindItem(inIndex) instudioSplineBuilderEx1.ConstraintManager.Delete(GCDtoDelete) numPoles = instudioSplineBuilderEx1.ConstraintManager.Length delPoles += 1 End Sub Function SelectObjects(prompt As String, _ ByRef selObj As NXObject()) As Selection.Response Dim theUI As UI = UI.GetUI Dim typeArray() As Selection.SelectionType = {Selection.SelectionType.Curves} Dim resp As Selection.Response = theUI.SelectionManager.SelectObjects( _ prompt, "Selection", _ Selection.SelectionScope.AnyInAssembly, _ False, typeArray, selObj) If resp = Selection.Response.ObjectSelected Or _ resp = Selection.Response.ObjectSelectedByName Or _ resp = Selection.Response.Ok Then Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function End ModuleNX9 Win8.1 64bit i7-3770K 16GB Quadro2000
RE: Two poles of a spline sitting on top of each other
Regards,
Tomas
RE: Two poles of a spline sitting on top of each other
I like the idea of changing the color to highlight what was changed. I'd suggest keeping a copy of the original spline and changing the line font to dashed (or something other than solid) so the user can adjust the remaining pole to better approximate the original spline shape.
www.nxjournaling.com
RE: Two poles of a spline sitting on top of each other
RE: Two poles of a spline sitting on top of each other
http://www.eng-tips.com/viewthread.cfm?qid=375105
but your idea is interesting, I'll play around with it and see if it's a better solution, thanks!
NX9 Win8.1 64bit i7-3770K 16GB Quadro2000