Author Topic: splines with second degree curve data degrade?  (Read 9032 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
splines with second degree curve data degrade?
« on: December 15, 2011, 01:52:17 PM »
Hi there, recently I revised my old hyperbola.lsp & parabola.lsp and now I've found that CAD degrade SPLINE with data for second degree curve. I've used this Stefan's PDF that can be found here :
http://www.theswamp.org/index.php?topic=40003.0.msg452900#msg452900
Please, check my *.dwg where I've created 2 parabola SPLINE curves, one with curve extension level = 0, and other one with level = 10. I've used inverse construction method for obtain extension level endpoints... So, for parabola there are no formula calculations inside routine (only construction method), but that is why I've noticed this lack of SPLINE representation. I've checked parameters of start, mid, end points and they are for both splines 0.0, 0.5, 1.0... Maybe this is why representation isn't as expected for parabola with extension level 10 (start and end points are far away distant and parameters of curve near middle point are much the same almost 0.5 exactly, as for one with level 0, near middle point parameters vary more...

So here are codes for parabolas and hyperbolas :
http://www.theswamp.org/index.php?topic=48929.msg540574#msg540574

So am I wright if I conclude that after all it's better to use SPLINES with more points segmentation obtained using formulas for 2nd degree curves like parabola & hyperbola, than SPLINES with data for drawing 2nd degree curves with end points, central control vertex with its weight?

M.R.
:???:
« Last Edit: February 24, 2015, 11:59:30 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: splines with second degree curve data degrade?
« Reply #1 on: December 16, 2011, 02:56:11 AM »
Hi Marko

The parabola in your drawing is just fine. I think it looks sharp because of  approximation made by AutoCAD. Try to draw an Ellipse over it and you’ll see the same representation.
Take a look here (scroll down to Special Cases) http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ffa23ce210c4a30acaf-6f01.htm.
It says “You can create a spline with a parabolic shape by specifying a degree 2 spline created with exactly 3 control vertices”.  So you don’t need more control points for an exact representation, but it can be done, if you wish. See attached dwg.

ps. Sorry for not answering in the other thread, even if I promised... Glad that my .pdf helped.

SEANT

  • Bull Frog
  • Posts: 345
Re: splines with second degree curve data degrade?
« Reply #2 on: December 16, 2011, 03:01:04 AM »
I think the degradation is related to the inaccuracies of floating point math operations at those scales.  A “Point at Parameter” operation would typically require a math operation that squares numbers – thus amplifying the issue.

Even though you file gives an excellent visual representation of the problem, the actual percentage of error is still quite small.  I would be surprised if any elevated point count spline could match the accuracy level, given the scale shown.
Sean Tessier
AutoCAD 2016 Mechanical

ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #3 on: December 16, 2011, 04:47:32 AM »
Stefan, I saw your examples on the right showing parabolas with refined control vertexes... So I just refined with splinedit main CV with weight 1.0 to 2 new control vertexes and parabolas matches (level = 0 equal level = 10)... But now I don't know what shell we do with your ellipse? Using A2008, so I can't explode it to spline... Maybe that's just what it needs to be exploded into spline. Check my *.dwg now...

Sorry, for posting wrong *.dwg, it seems that after saving CAD didn't represented spline as it did just after splinedit - refine... So all I could do is splinedit from A2011 - A2012 and convert it to polyline with precision 99. Results are approximately correct... Still I don't know how you even draw that ellipse, but I read somewhere on www that if you draw it with variable PELLIPSE set to 1, you can draw it as polyline, and another method is to save dwg as DXF R 12 and after do DXFIN you'll get 3dpolyline from your ellipse, but I've tried this and I think that approximation is bad and for ellipse and for spline-parabola, and the third method is to offset ellipse for some amount and then offset it back - ellipse will be converted into spline (I offset your ellipse by 1.0 inside, splinedit -> polyline precision 13, and offset new polyline by 1.0 outside)... So in the end I'll post what I did best to simulate approximation of representation of extension level = 10 spline-parabola and approximation for your ellipse...

M.R.
« Last Edit: December 16, 2011, 07:18:13 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: splines with second degree curve data degrade?
« Reply #4 on: December 16, 2011, 06:39:21 AM »
...But now I don't know what shell we do with your ellipse?...
I drew the ellipse just to show you that is nothing wrong with your parabola. It appear sharp just like some other objects (ellipse in my sample) when its geometry is near to a degenerate geometry. When the opening of parabola is decreasing to zero, it becomes a line; so an ellipse, when its minor radius tends to zero.

I do not understand what you are trying to do with that parabola? Maybe you can explain better so we can find another solution.


ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #5 on: December 16, 2011, 06:48:37 AM »
Stefan, watch for my uploaded *.dwg and you'll see how big differences are between original splines, ellipses with newly created polylines from them...

I only wanted to show that CAD representation could be better even with so distant and degenerated objects, I thought that original entities would be presented more accurate than ones that are produced from them (thought that CAD will operate without limits at least for presentation purposes)...

M.R.
:)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: splines with second degree curve data degrade?
« Reply #6 on: December 16, 2011, 07:37:15 AM »
I only wanted to show that CAD representation could be better even with so distant and degenerated objects....

So it's just a representation issue... In this case, do you really need so long parabola? It is miles away from the picked points.
I would limit the value of x or y, depending on the opening of parabola.

If is a narrowed one, chose an x not larger then, say, 5 times the width of screen.
For a wider opening you could limit the y value.

ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #7 on: December 16, 2011, 07:43:48 AM »
When the opening of parabola is decreasing to zero, it becomes a line...

Opening of parabola is never going to be decreased to zero; their openings goes to infinity and closing never happens; that means also and for hyperbola, opening end points are tending to be closer to their corresponding asymptote, but end points never touches them no matter how big is branch of hyperbola... That is pure geometry analyses... And analyzing conic sections you can see that circle is stretched to ellipse, it is stretched so deep that ellipses brakes and first brake is parabola (other end point of ellipse went to infinity), end points of parabola are now end points of minor ellipses radius, after that parabola is stretched and it firstly becomes hyperbola with asymptotes almost parallel to each other and main axis of hyperbola, and then asymptotes tend to make acute angle, hyperbola is stretched even more, all to the point that asymptotes become one orthogonal axis to main axis of hyperbola and hyperbola becomes that single xline - asymptote... So only the end of stretch is closure infinity - xline of asymptote and it is orthogonal to main axis of stretching original circle as first special case of conic section... If stretching of circle is inside circle transforms to ellipse witch in the end degenerates to line that is orthogonal to axis of stretching...

Explanation of infinity stretching of main circle as first special case of conic section (cone+plane with normal = normal of cone) by M.R.

:)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: splines with second degree curve data degrade?
« Reply #8 on: December 16, 2011, 08:35:07 AM »
When the opening of parabola is decreasing to zero, it becomes a line...

Opening of parabola is never going to be decreased to zero; their openings goes to infinity and closing never happens; that means also and for hyperbola, opening end points are tending to be closer to their corresponding asymptote, but end points never touches them no matter how big is branch of hyperbola... That is pure geometry analyses... And analyzing conic sections you can see that circle is stretched to ellipse, it is stretched so deep that ellipses brakes and first brake is parabola (other end point of ellipse went to infinity), end points of parabola are now end points of minor ellipses radius, after that parabola is stretched and it firstly becomes hyperbola with asymptotes almost parallel to each other and main axis of hyperbola, and then asymptotes tend to make acute angle, hyperbola is stretched even more, all to the point that asymptotes become one orthogonal axis to main axis of hyperbola and hyperbola becomes that single xline - asymptote... So only the end of stretch is closure infinity - xline of asymptote and it is orthogonal to main axis of stretching original circle as first special case of conic section... If stretching of circle is inside circle transforms to ellipse witch in the end degenerates to line that is orthogonal to axis of stretching...

Explanation of infinity stretching of main circle as first special case of conic section (cone+plane with normal = normal of cone) by M.R.

:)
Very good explanations but you consider a fixed cone generator. If you start to narrow that cone then a parabola (or hyperbola) opening could tend to zero.

ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #9 on: December 16, 2011, 09:07:48 AM »
Very good explanations but you consider a fixed cone generator. If you start to narrow that cone then a parabola (or hyperbola) opening could tend to zero.

That's true, but in my case I draw parabola that has mathematically saying quadratic coefficient y=kx^2, witch means that k/=0, k/=~, => y/=0, y/=~; where ~ is infinity, and -~<x<~, so my parabola is never going to tend to close to zero... Even if that's supposed to happen, that is no real reason that CAD represent parabola near apex curvature with approximation to line, but to quadratic 2nd degree curvature like my example with extension level 0...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

SEANT

  • Bull Frog
  • Posts: 345
Re: splines with second degree curve data degrade?
« Reply #10 on: December 16, 2011, 05:07:59 PM »
In you first post I thought you were referring to AutoCAD’s inability to return an accurate MID osnap for the longer parabola.  I do believe that is related to the floating point issue I mentioned. 

See the attached – it has a similarly scaled parabola. 

The Properties Panel shows the two upper CPs symmetrically positioned either side of the lower point.  Still, AutoCAD does not give an accurate MID snap.

With regard to the faceted representation:  It seems that AutoCAD uses some running optimization unless forced into more accuracy.  With the attached file, draw a line from the point to the spline while invoking the TAN osnap.

The first thing we see is that the line snaps to the appropriate (perhaps mildly inaccurate) position, not on the more linear representation.  The interesting thing is that now a REGEN forces the spline to the proper curved path.  At least it does in AutoCAD 2012.  See the attached PDFs showing a before and after.
« Last Edit: December 24, 2011, 03:38:26 AM by SEANT »
Sean Tessier
AutoCAD 2016 Mechanical

ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #11 on: December 17, 2011, 06:25:08 AM »
SEANT, at first glance I thought you solved the problem (genial idea), but it works only for parabola... Now it happens that the real issue is an ellipse... Look to my *.dwg (I've tried the same - tan snap with ellipse - no success!!!)

M.R.
 :|
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

SEANT

  • Bull Frog
  • Posts: 345
Re: splines with second degree curve data degrade?
« Reply #12 on: December 17, 2011, 07:20:12 AM »
I believe AutoCAD treats an ELLIPSE as a hybrid object, i.e., the behind the scenes calculations use a NURB curve, but the ELLIPSE entity implements its own methods for REGENs and such.

For display purposes, you could recreate the ellipse via a degree 2 spline to get the same performance we saw with the parabola (see attached).  As a matter of fact, I originally intended to include that with my previous file.  Unfortunately, AutoCAD 2012 has a bug with regard to rational NURB curves, so the entity is not very reliable for subsequent GRIP edit operations.

http://forums.autodesk.com/t5/Drafting-Techniques/Bug-using-splines/td-p/3138850

I would not recommend its use for anything more than temporary display work.
Sean Tessier
AutoCAD 2016 Mechanical

ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #13 on: December 17, 2011, 10:13:55 AM »
You are genius SEANT... You just didn't mentioned that CV for quarter ellipse main tangents must have weight (sqrt 2)/2.0

M.R.
Thank you all for reply...
 :wink:
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

SEANT

  • Bull Frog
  • Posts: 345
Re: splines with second degree curve data degrade?
« Reply #14 on: December 17, 2011, 10:55:37 AM »
... You just didn't mentioned that CV for quarter ellipse main tangents must have weight (sqrt 2)/2.0 . . . .

Oh yeah.  Sorry, I forgot to make note of that.
Sean Tessier
AutoCAD 2016 Mechanical

ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #15 on: December 17, 2011, 12:19:25 PM »
Here, I've made conversion of an ellipse to spline by our conclusions... Perhaps now try to draw tangent and see what happens...

Code: [Select]
(defun c:el2spl ( / CE CH DXF11 DXF40 EL ELSPL PTST SP1 SP1CV SP1EN SP1ST SP2 SP2CV SP2EN SP2ST SP3 SP3CV SP3EN SP3ST SP4 SP4CV SP4EN SP4ST SPSS SS )
  (setq ss (ssget "_:E:S:L" '((0 . "ELLIPSE"))))
  (setq el (ssname ss 0))
  (setq ce (cdr (assoc 10 (entget el))))
  (setq dxf11 (cdr (assoc 11 (entget el))))
  (setq dxf40 (cdr (assoc 40 (entget el))))
  (setq ptst (mapcar '+ ce dxf11))
  (setq sp1st ptst)
  (setq sp1en (polar ce (+ (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp1cv (polar sp1st (+ (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp1 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (210 0.0 0.0 1.0) (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 sp1st) (cons 41 1.0) (cons 10 sp1cv) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 sp1en) (cons 41 1.0)) )))
  (setq sp2st sp1en)
  (setq sp2en (polar ce (angle ptst ce) (distance ptst ce)))
  (setq sp2cv (polar sp2en (+ (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp2 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (210 0.0 0.0 1.0) (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 sp2st) (cons 41 1.0) (cons 10 sp2cv) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 sp2en) (cons 41 1.0)) )))
  (setq sp3st sp2en)
  (setq sp3en (polar ce (- (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp3cv (polar sp3st (- (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp3 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (210 0.0 0.0 1.0) (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 sp3st) (cons 41 1.0) (cons 10 sp3cv) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 sp3en) (cons 41 1.0)) )))
  (setq sp4st sp3en)
  (setq sp4en sp1st)
  (setq sp4cv (polar sp4en (- (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp4 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (210 0.0 0.0 1.0) (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 sp4st) (cons 41 1.0) (cons 10 sp4cv) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 sp4en) (cons 41 1.0)) )))
  (setq spss (ssadd))
  (ssadd sp1 spss)
  (ssadd sp2 spss)
  (ssadd sp3 spss)
  (ssadd sp4 spss)
  (vl-cmdf "_.splinedit" sp1 "j" spss "" "")
  (setq elspl (entlast))
  (initget 1 "Yes No")
  (setq ch (getkword "\nErase original ellipse and leave spline (Yes/No) : "))
  (if (eq ch "Yes") (entdel el))
(princ)
)

Regards, M.R.
:)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #16 on: December 17, 2011, 12:39:55 PM »
No success with tan trick, but you can now convert elliptic spline to pline with splinedit and set precision up to 99...

M.R. (I don't know though why now trick with tan doesn't work - with 1 quarter of ellipse it worked)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3278
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #17 on: December 17, 2011, 12:55:26 PM »
Here now the trick with tan works... Only thing is that now ellipse is converted into 4 quarters splines...

Code: [Select]
(defun c:el2spl ( / CE CH DXF11 DXF40 EL ELSPL PTST SP1 SP1CV SP1EN SP1ST SP2 SP2CV SP2EN SP2ST SP3 SP3CV SP3EN SP3ST SP4 SP4CV SP4EN SP4ST SS )
  (setq ss (ssget "_:E:S:L" '((0 . "ELLIPSE"))))
  (setq el (ssname ss 0))
  (setq ce (cdr (assoc 10 (entget el))))
  (setq dxf11 (cdr (assoc 11 (entget el))))
  (setq dxf40 (cdr (assoc 40 (entget el))))
  (setq ptst (mapcar '+ ce dxf11))
  (setq sp1st ptst)
  (setq sp1en (polar ce (+ (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp1cv (polar sp1st (+ (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp1 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (210 0.0 0.0 1.0) (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 sp1st) (cons 41 1.0) (cons 10 sp1cv) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 sp1en) (cons 41 1.0)) )))
  (setq sp2st sp1en)
  (setq sp2en (polar ce (angle ptst ce) (distance ptst ce)))
  (setq sp2cv (polar sp2en (+ (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp2 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (210 0.0 0.0 1.0) (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 sp2st) (cons 41 1.0) (cons 10 sp2cv) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 sp2en) (cons 41 1.0)) )))
  (setq sp3st sp2en)
  (setq sp3en (polar ce (- (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp3cv (polar sp3st (- (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp3 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (210 0.0 0.0 1.0) (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 sp3st) (cons 41 1.0) (cons 10 sp3cv) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 sp3en) (cons 41 1.0)) )))
  (setq sp4st sp3en)
  (setq sp4en sp1st)
  (setq sp4cv (polar sp4en (- (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  (setq sp4 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (210 0.0 0.0 1.0) (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 sp4st) (cons 41 1.0) (cons 10 sp4cv) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 sp4en) (cons 41 1.0)) )))
  (initget 1 "Yes No")
  (setq ch (getkword "\nErase original ellipse and leave spline (Yes/No) : "))
  (if (eq ch "Yes") (entdel el))
(princ)
)

[EDIT : Added another code]

Code - Auto/Visual Lisp: [Select]
  1. (defun c:el2spls ( / ce ch dxf11 dxf40 el elspl i ptst sp1 sp1cv sp1en sp1st sp2 sp2cv sp2en sp2st sp3 sp3cv sp3en sp3st sp4 sp4cv sp4en sp4st spss ss stpt enpt )
  2.   (setq ss (ssget "_:L" '((0 . "ELLIPSE"))))
  3.   (repeat (setq i (sslength ss))
  4.     (setq el (ssname ss (setq i (1- i))))
  5.     (command "_.ucs" "e" el)
  6.     (setq ce (cdr (assoc 10 (entget el))))
  7.     (setq dxf11 (cdr (assoc 11 (entget el))))
  8.     (setq dxf40 (cdr (assoc 40 (entget el))))
  9.     (setq ptst (mapcar '+ ce dxf11))
  10.     (setq ptst (trans ptst 0 1))
  11.     (setq ce (trans ce 0 1))
  12.     (setq sp1st ptst)
  13.     (setq sp1en (polar ce (+ (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  14.     (setq sp1cv (polar sp1st (+ (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  15.     (setq sp1 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 (trans sp1st 1 0)) (cons 41 1.0) (cons 10 (trans sp1cv 1 0)) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 (trans sp1en 1 0)) (cons 41 1.0) (assoc 210 (entget el))) )))
  16.     (setq sp2st sp1en)
  17.     (setq sp2en (polar ce (angle ptst ce) (distance ptst ce)))
  18.     (setq sp2cv (polar sp2en (+ (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  19.     (setq sp2 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 (trans sp2st 1 0)) (cons 41 1.0) (cons 10 (trans sp2cv 1 0)) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 (trans sp2en 1 0)) (cons 41 1.0) (assoc 210 (entget el))) )))
  20.     (setq sp3st sp2en)
  21.     (setq sp3en (polar ce (- (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  22.     (setq sp3cv (polar sp3st (- (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  23.     (setq sp3 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 (trans sp3st 1 0)) (cons 41 1.0) (cons 10 (trans sp3cv 1 0)) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 (trans sp3en 1 0)) (cons 41 1.0) (assoc 210 (entget el))) )))
  24.     (setq sp4st sp3en)
  25.     (setq sp4en sp1st)
  26.     (setq sp4cv (polar sp4en (- (angle ptst ce) (/ PI 2.0)) (* dxf40 (distance ptst ce))))
  27.     (setq sp4 (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (70 . 12) (71 . 2) (72 . 6) (73 . 3) (74 . 0) (42 . 1.0e-010) (43 . 1.0e-010) (40 . 0.0) (40 . 0.0) (40 . 0.0) (40 . 1.0) (40 . 1.0) (40 . 1.0)) (list (cons 10 (trans sp4st 1 0)) (cons 41 1.0) (cons 10 (trans sp4cv 1 0)) (cons 41 (/ (sqrt 2.0) 2.0)) (cons 10 (trans sp4en 1 0)) (cons 41 1.0) (assoc 210 (entget el))) )))
  28.     (setq spss (ssadd))
  29.     (setq stpt (vlax-curve-getstartpoint el))
  30.     (setq enpt (vlax-curve-getendpoint el))
  31.     (command "_.ucs" "w")
  32.     (cond
  33.       ((vlax-curve-getparamatpoint sp1 stpt)
  34.        (ssadd sp1 spss)
  35.        (ssadd sp2 spss)
  36.        (ssadd sp3 spss)
  37.        (ssadd sp4 spss)
  38.        (vl-cmdf "_.splinedit" sp1 "j" spss "" "")
  39.        (setq elspl (entlast))
  40.       )
  41.       ((vlax-curve-getparamatpoint sp2 stpt)
  42.        (ssadd sp2 spss)
  43.        (ssadd sp3 spss)
  44.        (ssadd sp4 spss)
  45.        (ssadd sp1 spss)
  46.        (vl-cmdf "_.splinedit" sp2 "j" spss "" "")
  47.        (setq elspl (entlast))
  48.       )
  49.       ((vlax-curve-getparamatpoint sp3 stpt)
  50.        (ssadd sp3 spss)
  51.        (ssadd sp4 spss)
  52.        (ssadd sp1 spss)
  53.        (ssadd sp2 spss)
  54.        (vl-cmdf "_.splinedit" sp3 "j" spss "" "")
  55.        (setq elspl (entlast))
  56.       )
  57.       ((vlax-curve-getparamatpoint sp4 stpt)
  58.        (ssadd sp4 spss)
  59.        (ssadd sp1 spss)
  60.        (ssadd sp2 spss)
  61.        (ssadd sp3 spss)
  62.        (vl-cmdf "_.splinedit" sp4 "j" spss "" "")
  63.        (setq elspl (entlast))
  64.       )
  65.     )
  66.     (command "_.break" elspl stpt enpt)
  67.     (entupd (cdr (assoc -1 (entmod (subst (assoc 8 (entget el)) (assoc 8 (entget elspl)) (entget elspl))))))
  68.     (if (assoc 62 (entget el)) (entupd (cdr (assoc -1 (entmod (append (entget elspl) (list (assoc 62 (entget el)))))))))
  69.     (if (assoc 420 (entget el)) (entupd (cdr (assoc -1 (entmod (append (entget elspl) (list (assoc 420 (entget el)))))))))
  70.     (entdel el)
  71.     (command "_.ucs" "p")
  72.     (command "_.ucs" "p")
  73.   )
  74.   (princ)
  75. )
  76.  

M.R.
« Last Edit: March 11, 2015, 02:33:36 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

SEANT

  • Bull Frog
  • Posts: 345
Re: splines with second degree curve data degrade?
« Reply #18 on: December 17, 2011, 04:45:12 PM »
Interesting work.  As programmers, investigating how AutoCAD responds in all situations justifies this type of effort. 

I am curious, though:  Is there a design/documentation need for the extreme entities contained in the previous files?
Sean Tessier
AutoCAD 2016 Mechanical