Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/21/2024 in all areas

  1. Hi @Pixel_Outlaw, I'm the author of BabaCAD software and I just want to encourage you to start programming lisp in BabaCAD. There are so many users (more and more every day) switching to BabaCAD because of it's low price and because it has Lisp support, but also for developers, there are also C# (dot.Net) and VisualBasic programming API and soon there will be Python API for BabaCAD Home users. You can use your knowledge and experience in Lisp programming to help BabaCAD users to speed up their drafting work. I'm ready to put your contact (for free, no obligations) as a BabaCAD lisp developer on BabaCAD's website main page, so please feel free to contact me.
    1 point
  2. 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. Responding y to the SplineCurvatue command yields: 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. 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. 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. (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))))
    1 point
×
×
  • Create New...