Spline to polyline to arcs to simplified arcs

Spline to polyline to arcs to simplified arcs

xin_yi_wang
Enthusiast Enthusiast
12,826 Views
18 Replies
Message 1 of 19

Spline to polyline to arcs to simplified arcs

xin_yi_wang
Enthusiast
Enthusiast
Hi all, I've got a spline free form building and I need to make them into arc segments. I've found out about FLATTEN and it seems to be working fine. However the problem with that is that there are way too many segments and I'm wondering if you can tell Autocad to combine some of these arcs as new arcs - as close to the original shape as possible (something like 3dsmax smooth/tessellate in a way? i haven't used 3dsmax for so long so can't remember)? What's more is that I'm limited to have only 10 types of arcs/radius in the entire building - I mean, how should I even begin with? Any help would be much appreciated! Cheers
0 Likes
12,827 Views
18 Replies
Replies (18)
Message 2 of 19

xin_yi_wang
Enthusiast
Enthusiast

Please see attached image as a sample. The red line is the profile of the glazing line and basically I need to make them into equal chord distance and different arcs with different radius but limited to a maximum of 10 types in total (there are other areas like this, about 20, but all in completely different shapes). As you can see if I pick the intersections of the red line and the diameter lines they form chords with different length. I don't know what to start with or how to proceed... 😞

glazing shape into arcs.PNG

0 Likes
Message 3 of 19

xin_yi_wang
Enthusiast
Enthusiast

sorry didn't hit attach. please find the image here

0 Likes
Message 4 of 19

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

the image does not help, the drawing would be needed.

 

Generally to:

>> I've got a spline free form building and I need to make them into arc segments

You can use command _SPLINEDIT, option "convert to Polyline" to create a polyline from that spline

 

>> there are way too many segments

Using the above command and option asks you for a precision (between 0 and 99, 0 means lowest precision)

 

>> make them into arc segments

The above command reads the setting of sysvar PLINECONVERTMODE to decide that the resulting segments (when converting a spline to polyline) should be lines or arcs, if you want to get arcs then set PLINECONVERTMODE to 1 before converting the spline.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 5 of 19

xin_yi_wang
Enthusiast
Enthusiast

Thanks @Alfred.NESWADBA!!

 

I've tried your method before but the result isn't what I wanted.

 

Please find attached sample dwg and the screen capture image for reference.

 

spline to arc sample image.PNG 

 

What I've also been testing is to manually work out the arcs with a consistent chord length and try to match with the original free form as close as possible. However I think any some points the chord length need to change, otherwise it's almost impossible to match the original form.

 

Hope this is helpful.

 

Cheers.

0 Likes
Message 6 of 19

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> but the result isn't what I wanted

What is it what you want?

What is the difference between your screenshot and your needs?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 7 of 19

braudpat
Mentor
Mentor

 

Hello from France

 

Welcome to the Autodesk / AutoCAD Forums !

 

Maybe this nice french routine "SPL2PL" from Gilles (gile) could help you !?

 

Please Test - Load this VLisp routine with the command: APPLOAD <Enter>

And then launch it with the command: SPL2PL <Enter>

 

Regards, Patrice


A few translations :

 

Spécifiez la longueur minimum des segments: 

 >>> Specify minimum length of segments:

 

 

Supprimer la spline ? [Oui/Non] <Oui>: 

 >>> Delete/Erase the original Spline:

 

 

Spécifiez la longueur de segment minimale: 

>>> Specify the minimum length for the segment:

 

 

 

;; SplineToPline (gile) 10/02/08
;; Crée une polyligne à partir d'une spline.
;; La polyligne est constituée exclusivement de segments en arc de cercle.
;; La longueur de chaque segment est calculée en fonction des changements
;; de courbure de la spline et de la longueur minimale des segments.
;;
;; Arguments
;; spl : le nom d'entité de la spline (ename)
;; seg : la longueur minimale des segments (entier ou réel)

(defun SplineToPline (spl    seg    /	   ent	  dis	 nor	len    ptg1
		      pto1   elv    lsto   deriv1 n	 loop	ptg2   pto2
		      deriv2 ang    blst   pl
		     )
  (vl-load-com)
  (or *acdoc*
      (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
  )
  (and (= (type spl) 'VLA-OBJECT)
       (setq spl (vlax-vla-object->ename spl)
	     ent T
       )
  )
  (setq	nor    (cdr (assoc 210 (entget spl)))
	len    (vlax-curve-getDistAtParam spl (vlax-curve-getEndParam spl))
	seg    (/ len (fix (/ len seg)))
	dis    seg
	ptg1   (vlax-curve-getPointAtDist spl 0)
	pto1   (trans ptg1 0 nor)
	elv    (caddr pto1)
	lsto   (cons pto1 lsto)
	deriv1 (angle '(0 0)
		      (trans (vlax-curve-getFirstDeriv
			       spl
			       (vlax-curve-getParamAtPoint spl ptg1)
			     )
			     0
			     nor
		      )
	       )
	n      0
  )
  (while (< dis len)
    (setq loop T)
    (while loop
      (if (and (< dis len)
	       (setq ptg2 (vlax-curve-getPointAtDist spl dis))
	       (setq pto2 (trans ptg2 0 nor))
	       (equal (- (setq deriv2
				(angle
				  '(0 0)
				  (trans (vlax-curve-getFirstDeriv
					   spl
					   (vlax-curve-getParamAtPoint spl ptg2)
					 )
					 0
					 nor
				  )
				)
			 )
			 (setq ang (angle pto1 pto2))
		      )
		      (- ang deriv1)
		      0.01
	       )
	  )
	(setq dis (+ dis seg))
	(setq loop nil)
      )
    )
    (setq lsto	 (cons pto2 lsto)
	  blst	 (cons (cons n (tan (/ (- ang deriv1) 2.0))) blst)
	  ptg1	 ptg2
	  pto1	 pto2
	  deriv1 deriv2
	  dis	 (+ dis seg)
	  n	 (1+ n)
    )
  )
  (setq	lsto (cons (trans (vlax-curve-getEndPoint spl) 0 nor) lsto)
	blst (cons
	       (cons
		 n
		 (tan
		   (/ (- (angle (cadr lsto) (car lsto))
			 (angle	'(0 0)
				(trans
				  (vlax-curve-getFirstDeriv
				    spl
				    (vlax-curve-getParamAtPoint spl ptg1)
				  )
				  0
				  nor
				)
			 )
		      )
		      2.0
		   )
		 )
	       )
	       blst
	     )
	lsto (reverse (mapcar '(lambda (p) (list (car p) (cadr p)))
			      (if (vlax-curve-isClosed spl)
				(cdr lsto)
				lsto
			      )
		      )
	     )
  )
  (setq	pl (vlax-invoke
	     (vla-get-ModelSpace *acdoc*)
	     'addLightWeightPolyline
	     (apply 'append lsto)
	   )
  )
  (mapcar '(lambda (x) (vla-setBulge pl (car x) (cdr x)))
	  blst
  )
  (if (vlax-curve-IsClosed spl)
    (vla-put-Closed pl :vlax-true)
  )
  (vla-put-Normal pl (vlax-3d-point nor))
  (vla-put-Elevation pl elv)
  (vla-getXData (vlax-ename->vla-object spl) "" 'typ 'val)
  (and typ (vla-setXData pl typ val))
  (if (not ent)
    (vlax-vla-object->ename pl)
    pl
  )
)

;; Tan
;; Retourne la tangente de l'angle

(defun tan (a) (/ (sin a) (cos a)))

;; SPL2PL
;; Fonction principale

(defun c:spl2pl	(/ spl seg loop)
  (vl-load-com)
  (while (not
	   (and
	     (setq spl (car (entsel "\nSélectionnez une spline: ")))
	     (= (cdr (assoc 0 (entget spl))) "SPLINE")
	     (vlax-curve-IsPlanar spl)
	   )
	 )
  )
  (setq loop T)
  (while loop
    (initget 7)
    (setq seg (getdist "\nSpécifiez la longueur minimum des segments: "))
    (SplineToPline spl seg)
    (initget "Oui Non")
    (if	(= (getkword "\nConserver le résultat ? [Oui/Non] <Oui>: ")
	   "Non"
	)
      (entdel (entlast))
      (setq loop nil)
    )
  )
  (initget "Oui Non")
  (if (/= (getkword "\nSupprimer la spline ? [Oui/Non] <Oui>: ")
	  "Non"
      )
    (entdel spl)
  )
  (princ)
)

(defun c:polyspline (/ seg spl)
  (initget 7)
  (and
    (setq seg (getdist "\Spécifiez la longueur de segment minimale: "))
    (vl-cmdf "_.spline")
    (while (/= 0 (getvar "CMDACTIVE"))
      (vl-cmdf pause)
    )
    (setq spl (entlast))
    (SplineToPline (entlast) seg)
    (entdel spl)
  )
  (princ)
)

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 8 of 19

xin_yi_wang
Enthusiast
Enthusiast

Hi @Alfred.NESWADBA

 

The red free form shape is what I want - at the moment it's just spline - I would like to have them all in arcs with a consistent chord length as much as possible - to match the original shape as close as possible.

 

You can see my intention from the manual ways I've tried in the image/dwg file.

 

Regards

0 Likes
Message 9 of 19

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> I would like to have them all in arcs with a consistent chord length

Sorry, have not seen that request yet. Hard to do that also in theory (consistent coord length for a spline with quite different curvature)

IMHO that can't be done out-of-the-box, you'll need a tool to do that or by manually.

 

- alfred-

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 10 of 19

xin_yi_wang
Enthusiast
Enthusiast

hi @braudpat

 

Thanks for that! It looks interesting.

 

Would you mind elaborate a bit more on how to run this routine? I'm unfamiliar with it as I haven't done anything like this before.

 

Cheers

0 Likes
Message 11 of 19

xin_yi_wang
Enthusiast
Enthusiast

@Alfred.NESWADBA

 

Thanks Alf.

 

That's what I thought. I'm just doing it manually, and slowly 😞

0 Likes
Message 12 of 19

braudpat
Mentor
Mentor

 

 

Hello

 

1) Please Test - Load this VLisp routine with the command: APPLOAD <Enter>

 

And then launch it with the command: SPL2PL <Enter>

 

 

2) With this SPL2PL routine, you will get a BEAUTIFUL PLine (mainly created with Arcs and a few Lines)

 

 

3) Sorry I have forgotten one translation ...

 

Conserver le résultat ? [Oui/Non] <Oui>: 

>>> Keep the result:

 

 

Regards, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 13 of 19

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> I'm just doing it manually, and slowly

If Pat's lisp does not help you might get it done by running command _DIVIDE or _MEASURE, that creates points in equal distances along your spline, could be helpful for getting object snap positions!

 

- alfred -

PS: for points: check command PTYPE to set the style of the points to show them (could be hidden or too small to be visible)

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 14 of 19

xin_yi_wang
Enthusiast
Enthusiast

hi @braudpat

 

Thanks for the lisp file. It worked in some way but still I need to manually change them after. Also I need to get a whole number e.g. 2500mm or 3000mm for the chord lengths so I would probably just manually place them as close as possible.

 

Thank you very much again for your help!

 

spl2pl result.PNG

0 Likes
Message 15 of 19

xin_yi_wang
Enthusiast
Enthusiast

@Alfred.NESWADBA

 

Thanks Alf.

 

I've ran the lisp and it's somewhat getting there but not exactly so I will still need to draw/adjust them manually.

 

The _MEASURE/_DIVIDE/_DTYPE are all very good suggestions.

 

It could be used as a starting/reference points but I'd still need to draw the chords in whole number e.g. 2500/3000mm.

 

Thank you for the input Alf!

0 Likes
Message 16 of 19

Nizar.Sayegh
Explorer
Explorer

Thanks for the Lisp braudpat, I'm using it and it's the best lisp for the quality of polylines produced.

If it could be used on multiple s-plines it would be much better and faster.

0 Likes
Message 17 of 19

rycerz44
Explorer
Explorer

I've been messing with this for days and the answer was blindingly obvious (at least for my purposes):

 

Explode the spline and join the subsequent lines and polylines which include simple arcs to form a perfect fit against the original spline.

 

Voila.

0 Likes
Message 18 of 19

rycerz44
Explorer
Explorer
Oops, sorry- I forgot to mention step 2, which is "flatten". So the process is:

1. Explode the splines.
2. Flatten the splines.
3. Join the polylines.

Everything (meaning new polylines with arcs) should now line up perfectly with the previous splinework.
0 Likes
Message 19 of 19

gle502
Explorer
Explorer

Attached is a version with anglicized user prompts.  I also added a reminder at the end for the command invoke.   This is a great lisp!  Thank you braudpat for sharing.