Jump to content

convert spline to arc..?


kalathilanwar

Recommended Posts

Hai sir,

 

how can i convert a arc shaped spline to arc.?

i need to get the radius of that spline..is there any way to get the radius of arc shaped spline.?

ur helpings will be highly appriciated....

thanks

Link to comment
Share on other sites

Guest Alan Cullen

Basically, no. What you have to do is draw a three point arc over sections of the spline until you get them as close as you can to what you want. Then join them all to form a polyline.

 

Then you can get the radius of various sections, and there will be many.

Link to comment
Share on other sites

...is there any way to get the radius of arc shaped spline.?

 

Basically, yes. What you will have to do is -

Make sure you are in top view 2D wireframe shademode.

Run the Flatten command and accept the default No option when it prompts about removing hidden lines.

Run the Explode command on the lwpolyline resulting from the Flatten command.

You will now have a series of arcs.

Run the List command to retrieve the radii.

 

This is very useful for generating CNC G-code.

Link to comment
Share on other sites

  • 1 year later...
  • 3 years later...

this is exactly what i needed - very helpful!

 

Make sure you are in top view 2D wireframe shademode.

Run the Flatten command and accept the default No option when it prompts about removing hidden lines.

Link to comment
Share on other sites

  • 1 year later...

You can try out the new SPLINECAM app in Autodesk AppStore or download it from autocam2d.com/download link.

 

It converts splines to polylines/polyarcs with optimal number of vertices and smoothness.

 

regards

cncpatriot

 

Basically, yes. What you will have to do is -

Make sure you are in top view 2D wireframe shademode.

Run the Flatten command and accept the default No option when it prompts about removing hidden lines.

Run the Explode command on the lwpolyline resulting from the Flatten command.

You will now have a series of arcs.

Run the List command to retrieve the radii.

 

This is very useful for generating CNC G-code.

Link to comment
Share on other sites

  • 10 years later...
  • 4 months later...

The LISP program below will determine the instantaneous radius of curvature for multiple points along a spline then draw a line from the point on the spline to its center of curvature. For example, in the image below the yellow spline has an approximate arc segment where it is near the green circle.

image.png.f6fe4d54331ea6b116f3bae966d5c10a.png

 Responding  y to the SplineCurvatue command yields:

image.thumb.png.c48c8ee361a1a4b45247405fbca37d38.png

Each white line goes from the spline to the center of curvature for that point.  Since we are interested only in the portion of the spline that runs along the circle we can delete most of the other radial lines yielding the following. The center for the approximating arc would be in the area noted in red.  If the spline more closely fit an arc the line ends would be closer togther.

image.png.4334df65f5ce0c5559d59b63c98700b5.png

The program provides good feedback as to how "arc-like" a portion of a spline may be. It can be used on 2D and 3D splines.

 

The program can also display the curvature of a spline (the inverse of the radius of curvature) where a short line shows where the spline is almost flat and longer lines indicate a tighter radius of curvature.

image.png.124ed6355b89dae83f685474c3ed66f4.png

 

Note, an exact 90° arc can be created with a spline with 3 Control Vertices as show below in red against a green circle.  The weight of the first and third CV is 1 and the second CV weight is 0.7070 = (square root of 2)/2.  As can be seen here all the lines for the instanteous centers converge to the same point.

image.png.ce6d998467bd238875ea3410954d082d.png

 

(defun C:SplineCurvatue (/ path inc n osm par der1 der2 curva p perp normv p2 sf
	       curveType ans)
; = Degree Of Curvature - Lines
; Creates curvature lines or radius-of-curvature lines
; normal to a spline.
; LRM 8/18/2022 edited to place curvature vectors outside  
  (setq
    path (car (entsel))
    inc	 (/ (vlax-curve-getEndParam path) 100)
    n	 0
    osm	 (getvar 'osmode)
  )
  (setvar 'osmode 0)
  (setvar "cmdecho" 0)
  (initget "y n")
  (setq ans (getkword  "Do you want radius-of-curvature instead of curvature? [y/n] <n>: "))
	(if (= ans "y")
	   (setq curveType 1)
	   (setq curveType 2
		 sf	   (getdist "Enter scale factor.")
	   )
	)
  (repeat 100
    (setq par (* inc n))
    (setq der1 (vlax-curve-getfirstDeriv path par)
	  der2 (vlax-curve-getSecondDeriv path par)
    )
    ; calculate curvature at point par
    (setq d (distance '(0 0 0) (cross der1 der2)))
    (if	(> (abs d) 1.0e-15)
      (progn
	(setq curva (/ (expt (distance '(0 0 0) der1) 3) d))
	(if (= curveType 2)
	    (setq curva (* -1. (* sf (/ 1. curva))))
	  )
	(princ "\n") (princ n)
	(princ "   curvature = ") (princ curva)
	(setq p	    (vlax-curve-getPointAtParam path par)
	      perp  (unitv (cross der1 (cross der2 der1)))
	      normv (mapcar '* perp (list curva curva curva))
	      p2    (mapcar '+ p normv)
	)
	(command "_.line" p p2 "")
      )					; end progn
    )
    (setq n (1+ n))
  )
  (setvar 'osmode osm)
  (setvar "cmdecho" 1)
  (princ)
)


  ;;; Compute the cross product of 2 vectors a and b
(defun cross (a b / crs)
  (setq	crs (list
	      (- (* (nth 1 a) (nth 2 b))
		 (* (nth 1 b) (nth 2 a))
	      )
	      (- (* (nth 0 b) (nth 2 a))
		 (* (nth 0 a) (nth 2 b))
	      )
	      (- (* (nth 0 a) (nth 1 b))
		 (* (nth 0 b) (nth 1 a))
	      )
	    )				;end list
  )					;end setq c
)					;end cross
  (defun unitV ( v / d)
  (setq d (distance '(0 0 0) v)
	d (mapcar '/ v (list d d d))))

 

 

 

image.png

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...