GP_ Posted October 5, 2014 Posted October 5, 2014 The code is not so nice but, for my use, it seems to work. Ciao HelixAlongPath.LSP Quote
hanhphuc Posted October 6, 2014 Posted October 6, 2014 @thanks for sharing GP. amazing Excellent work Gian, well done! agree.. utilise geomcal.arx function nicely. Quote
GP_ Posted October 6, 2014 Author Posted October 6, 2014 @ Lee @ hanhphuc @ Dadgad Thanks, I am very happy that you like it Quote
David Bethel Posted October 6, 2014 Posted October 6, 2014 Congrats! I made something similar way back when. I had various rope / cable / hoses / IBeams as profiles. Pretty cool but limited to 255 vertices meshes. I remember it being a pretty intense project. Your final products look very good -David Quote
GP_ Posted October 7, 2014 Author Posted October 7, 2014 Thanks SLW210 Thanks David Thank you all for the flattering comments. Quote
d0gMa Posted August 8, 2015 Posted August 8, 2015 The code is not so nice but, for my use, it seems to work. Ciao [ATTACH=CONFIG]51161[/ATTACH] [ATTACH=CONFIG]51162[/ATTACH] [ATTACH=CONFIG]51163[/ATTACH] You are a beautiful person Quote
GP_ Posted August 10, 2015 Author Posted August 10, 2015 You are a beautiful person Wow... Thank you Quote
rhgrafix Posted May 6, 2020 Posted May 6, 2020 (edited) That is awesome! If I wanted to reverse the direction of the helix turns, which line/value would I change? I tried clicking the other end of the path and it didn't change turn direction. If I knew what I was doing, I would add a prompt asking for CW or CCW, easy fix? (in the mean time, I can mirror my path, run HELIX2 then mirror it all back). Thanks! Edited May 6, 2020 by rhgrafix Thought of a temporary work-around. Quote
ibach Posted October 5 Posted October 5 (edited) Helix tool in AutoCAD seems to be the best way to draw a ramp in 3D... The only thing it is missing is the possibility to enter number of turns by selecting the angle of the ramp that is circular... To do that i need to measure the given angle and manually calculate number of turns (<1) and input the number back to helix properties... see the picture, please... I would love to have a lisp that would allow that input selecting the two lines defining alpha... e.g. if α=60, the number of turns is 60/360=0.16666667 which i would not like to be only 8 decimals but the max of accuracy AutoCAD can achieve... Can anyone help with that? Edited October 5 by ibach Quote
marko_ribar Posted October 5 Posted October 5 For maximal accuracy that CAD can provide, check (ftoa) sub function... (defun ftoa ( n / m a s b ) (if (numberp n) (progn (setq m (fix ((if (< n 0) - +) n 1e-8))) (setq a (abs (- n m))) (setq m (itoa m)) (setq s "") (while (and (not (equal a 0.0 1e-6)) (setq b (fix (* a 10.0)))) (setq s (strcat s (itoa b))) (setq a (- (* a 10.0) b)) ) (if (= (type n) 'int) m (if (= s "") m (if (and (= m "0") (< n 0)) (strcat "-" m "." s) (strcat m "." s) ) ) ) ) ) ) Quote
ibach Posted October 5 Posted October 5 (edited) That would be maximal displayed accuracy... I believe that internal calculation accuracy in Auto CAD is at least 1e-20 if not greater. That is the reason i'd love to have the angle input as selection of two defining lines, not as an output of measure command in the first place. Edited October 5 by ibach Quote
lrm Posted October 6 Posted October 6 @marko_ribar Very interesting! I thought that AutoCAD would carry the approximately 16 significant figures (per the 64 bit floating point standard) for all floating point calculations. It looks like the results are only to 6 significat figures. Why? I tested your code with the following results. (defun c:test (/ d e f g) (setq d (getreal "\nEnter 1st number: ")) (setq e (getreal "\nEnter 2nd number: ")) (setq f (/ d e)) (princ "\n first/second = ") (princ f) (setq g (ftoa (/ d e))) (princ "\n FTOA first/second = ") (princ g) (princ) ) (defun ftoa (n / m a s b) (if (numberp n) (progn (setq m (fix ((if (< n 0) - + ) n 1e-8 ) ) ) (setq a (abs (- n m))) (setq m (itoa m)) (setq s "") (while (and (not (equal a 0.0 1e-6)) (setq b (fix (* a 10.0)))) (setq s (strcat s (itoa b))) (setq a (- (* a 10.0) b)) ) (if (= (type n) 'int) m (if (= s "") m (if (and (= m "0") (< n 0)) (strcat "-" m "." s) (strcat m "." s) ) ) ) ) ) ) Quote
ibach Posted October 7 Posted October 7 I'm getting old.... So... I found following cute program... ;;; ReportAngle.LSP [Command name: RAng] ;;; To Report to the Command: line the included Angle between ;; picked locations of two straight entities or sub-entities. ;;; Kent Cooper, November 2011 (defun C:RAng (/ *error* var ev getobj cmde aper) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break")) (princ (strcat "\nError: " errmsg)) ); if (setvar 'aperture aper) ); defun - *error* (defun var (typ); build variable name with number (read (strcat typ num)) ); defun - var (defun ev (typ); evaluate what's in variable name with number (eval (read (strcat typ num))) ); defun - ev (defun getobj (num / esel edata etype subedata subetype path) (while (not (and (setq esel (entsel (strcat "\nSelect linear object #" num " for Angle/Spacing Bisector: ")) edata (if esel (entget (car esel))) etype (if esel (cdr (assoc 0 edata))) ); setq (set (var "pick"); = pick1 or pick2 (osnap (cadr esel) "nea"); for (vlax-curve) later; also prohibits things like text elements of Dimensions ); set (wcmatch etype "LINE,*POLYLINE,@LINE,RAY,INSERT,HATCH,DIMENSION,LEADER,*SOLID,3DFACE,WIPEOUT,TRACE,REGION,IMAGE,VIEWPORT,TOLERANCE") (not (osnap (ev "pick") "cen")) ; if Polyline/Block/Region/3DSolid/angular Dimension, not on arc/ellipse segment or circle/arc/ellipse element (cond ((= etype "INSERT") (and ; then, use nested object -- same checks as above, except: ; no center Osnap check [earlier check covers it] ; no Insert or heavy Polyline object types [never returned by (nentselp)] ; add Vertex type for heavy Polylines (setq subedata (entget (car (nentselp (ev "pick")))) subetype (cdr (assoc 0 subedata)) ); setq (wcmatch subetype "LINE,LWPOLYLINE,VERTEX,@LINE,RAY,HATCH,DIMENSION,LEADER,*SOLID,3DFACE,WIPEOUT,TRACE,REGION,IMAGE,VIEWPORT,TOLERANCE") (if (= subetype "LEADER") (= (cdr (assoc 72 subedata)) 0) T); STraight, not Splined (if (= subetype "VERTEX") (= (boole 1 8 (cdr (assoc 70 subedata))) 0) T); not Splined 2DPolyline ); and ); Insert condition ((= etype "LEADER") (= (cdr (assoc 72 edata)) 0)); STraight, not Splined ((= etype "POLYLINE") (= (boole 1 4 (cdr (assoc 70 edata))) 0)); not Splined 2DPolyline (T) ; all other object types ); cond ); and ); not (prompt "\nNothing selected, or not a straight object with linearity --") ); while (if (wcmatch etype "LINE,*POLYLINE,XLINE,RAY"); vlax-curve-applicable types (progn ; then (setq path (car esel)) (set (var "ang"); = ang1 or ang2 (angle; then '(0 0 0) (vlax-curve-getFirstDeriv path (vlax-curve-getParamAtPoint path (ev "pick")) ); 1st deriv ); angle ); set ); progn - then (set ; else [other types] (var "ang"); = ang1 or ang2 (angle ; [will return 0 if Ray picked AT end or Xline picked AT origin/midpoint] (osnap (ev "pick") (if (= subetype "RAY") "nea" "mid")); account for Ray in Block [no midpoint] (osnap (ev "pick") (if (= subetype "XLINE") "nea" "end")); account for Xline in Block [no endpoint] ; curiosity: Xlines/Rays in Blocks extend normally on-screen, but cannot be selected ; or snapped to beyond some limit slightly outside other finite Block elements. ); angle ); set - else ); if ); defun - getobj (vl-load-com) (setq aper (getvar 'aperture)) (setvar 'aperture (getvar 'pickbox)); prevents Osnapping to inappropriate nearby things (getobj "1") (getobj "2") (setvar 'aperture aper) (if (or (equal ang1 ang2 1e-8) (equal (abs (- ang1 ang2)) pi 1e-8)); parallel (prompt (strcat "\nAngle: " (angtos 0))); then ; add mode/precision arguments if needed in something other than current settings (progn ; else - not parallel (setq appint (inters pick1 (polar pick1 ang1 1) pick2 (polar pick2 ang2 1) nil) ang1 (angle appint pick1); both outward [may reverse either or both] ang2 (angle appint pick2) angdiff (abs (- ang2 ang1)) ); setq (if (> angdiff pi) (setq angdiff (- (* pi 2) angdiff))); crossing-0 condition (prompt (strcat "\nAngle: " (angtos angdiff))) ; add mode/precision arguments if needed in something other than current settings ); progn ); if (princ) ); defun (prompt "\nType RAng to Report the Angle between straight entities or sub-entities.") (princ) It does give me the angle between two lines rounded to the angle rounding value defined in angle dimension rounding variable (AUPREC)... How do I get a value with no rounding at all, max precision that is, to be able to use it for further calculation?! Quote
ibach Posted October 7 Posted October 7 (edited) However... RTOS value in the following program does give me 14 decimal places maximum... (rtos number [mode [precision]]) ;TIP 978: ABL.LSP (C)1994, C.D. IDDINGS (defun C:abl () (setvar "cmdecho" 0) (defun *error* (msg) (princ "error : ") (princ msg) (terpri) ) (setq l1 (entsel "\nFor Angle Between Lines:-- Select First Line: ") lw1 (entget (car l1)) p11 (cdr (assoc 10 lw1)) p21 (cdr (assoc 11 lw1)) w1 (angle p11 p21) l2 (entsel "\nSelect Second Line: ") lw2 (entget (car l2)) p12 (cdr (assoc 10 lw2)) p22 (cdr (assoc 11 lw2)) w2 (angle p12 p22) w (abs (- w1 w2))) (if (> w pi)(setq w (- w pi))) (setq w (* w (/ 180 pi)) wc (- 180 w) a (min w wc) c (max w wc)) (prompt " Angle is = ") (prompt (rtos a 2 15)) (prompt " ** 180 - Angle is = ") (prompt (rtos c 2 15)) (princ) ) Changing the number to a higher value does not change the output... I also am not certain what is happening with rounding of Pi value... with its accuracy that is... I believe it is rounded to 3.14159. Edited October 7 by ibach Quote
ibach Posted October 7 Posted October 7 and... https://en.wikipedia.org/wiki/Double-precision_floating-point_format does state: "Common Lisp Common Lisp provides the types SHORT-FLOAT, SINGLE-FLOAT, DOUBLE-FLOAT and LONG-FLOAT. Most implementations provide SINGLE-FLOATs and DOUBLE-FLOATs with the other types appropriate synonyms. Common Lisp provides exceptions for catching floating-point underflows and overflows, and the inexact floating-point exception, as per IEEE 754. No infinities and NaNs are described in the ANSI standard, however, several implementations do provide these as extensions" that should provide 52 decimal places if i am not mistaking... Quote
ibach Posted October 7 Posted October 7 (edited) I did some more research on the input line values of ABL.LSP... I was surprised to find that lisp is using only 5 decimal values of 8 for start and end coordinate of the lines... I used princ command to return the values of the coordinates after the input and numbers like (2.38828 1.64482 0.0) instead of (2.38827872 1.64482430 0.0) has been displayed. Here i decided to check the values with printing a rtos 2 15 values after the selection and they did print out with 2.388278715325441 kind of values so i hope that is what the lisp is using internally but cannot be certain. Edited October 7 by ibach Quote
marko_ribar Posted October 7 Posted October 7 @lrm I see what you have done with testing (ftoa) sub... That errors appear only when you do calculations, but the main idea for (ftoa) is actually replacing (rtos) in inputs of numbers within (getreal) function like it was demonstrated here : https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/functional-lisp-just-trying-to-simplify/m-p/13064876/highlight/true#M472472 Anyway, thanks for your input... It's very interesting research... Quote
Recommended Posts
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.