ibach Posted October 7 Posted October 7 I'd really love to know if there is a reliable way to max the precision of the lisp procedure ... still looking for the answer. Quote
lrm Posted October 8 Posted October 8 Quote I'd really love to know if there is a reliable way to max the precision of the lisp procedure ... still looking for the answer. My first question was to determine what precision does AutoCAD use to store the number of turns of a helix. The image below shows two helixes . Both have a top and bottom radius of 1.0 and a height of 0. The number-of-turns for the helix on the left is 10.6666666666 (ten 6's). It shows an error of 0.00000002 for the subtended angle while the helix on the right shows the result of either using the explicit value of 10.66666666666 (eleven 6's) OR the result of a VLISP calculation. These results indicate to me that vlisp calculations are to mote than 8 significant figures and probably more like 15 (the 64 bit floating point practical guideline). I used AutoCAD's angular dimensioning features to measure the angles. They have a display maximum precision of 8 decimal places but coupled with the preceding 3 digits provide proof of at least 11 significant digits. Bottom line? I think you are safe using a VLISP calcuation for creating a helix to AutoCAD's maximum precision. Quote
ibach Posted October 8 Posted October 8 (edited) All right, I think I have it... I found a cute way to draw a precise 3D ramp quite fast Here is a video... https://screenrec.com/share/sN8kvXiJUY Result is a perfect solid. HelR.lsp SPS.lsp Edited October 8 by ibach Quote
ibach Posted October 8 Posted October 8 (edited) Now... The ramp above does not have an entry and exit slope with variable inclination... I want to add variable slope at top and bottom... Any ideas about correct geometrical approach are welcome! Edited October 8 by ibach Quote
lrm Posted October 10 Posted October 10 (edited) Let's assume that the centerline arc on the right in your drawing has a radius of 10. The curve starts wih z=0 and a slope of 0.0 and ends with z = 4. Let's also stipulate that the slope at the end of the 90° bend is 30°. Start by drawing a square 10 on a side. To simplify construction place the bottom left corner of the square at 0,0. Create a spline using the CV method (spline m cv) and define 3 CVs as noted using osnap end. This splne is NOT a true arc. To make an accurate arc change the weight of CV 2 to 0.707. I find that the easiest way to do this is to use the Properties panel. You now have a true arc represeted by a spline! Change the degree to 3. This will give us an additional CV to manipulate but will not change the shape of the curve. Since we want to have a slope of 0.0 at the start of the spline we will leave the z coordinates of CVs 1 and 2 at z=0. The first two CVs and the last two CVs of a spline define the tangent vectors at the ends. Set z = 4 for the CV number 4. We now want to determine the z value of CV 3 that will yield a slope of 30° at the end (CV 4). The properties panel indicates that CV 3 has an x coordinate of 5.8575. We know that: tan(30) = H/5.8575 where H is the z difference between CV 3 and CV 4. H = 3.3818 and the z coordinate of CV 3 is 4 - H = 0.6182. Setting Z = 0.6182 for CV 3 yields the following when viewed from the front. Here's a left view. A rectangel is swept along the spline. Note the unwanted twist at the end. The following used a twist angle of 20° for the sweep operation. The ramp is a gradually increasing slope ending with a 30° slope. A similar approach can be used for the other arc end. Edited October 10 by lrm Quote
ibach Posted October 11 Posted October 11 Not that you only answered my question, I think you killed questions more at once... The reason I referred to my ramp solution as "cute"... If you slice it by the plane trough the upper straight part of the ramp: Obviously there is no tangent with the surfaces of the floors and the curvature of the ramp but in axes of the ramp... Solution is satisfactory only as description and is a lousy geometrical model... but simple in its form and the file size is relatively small (I shall do a test here too), simple to extract data of the axes, the only level of description an architect would in practice ever need to produce... Mathematically i hate it. Representing both ends as tangential could be approached by the same method as you described... it is extracting data to think about latter on... Never-mind... So... If I get it well... Helix as such is graphically described as Spline that approximates same path... n periods + the rest of the circle if any... so we represent it with approximating spline... and we can manipulate ends as say a vector data... sort of 3 dimensional tangent... and the SWEEP function should be taking care of the rest keeping the sweeping square always parallel to the ground...? Let me try to model this between the power-outages here... Quote
ibach Posted October 11 Posted October 11 (edited) ...In the meantime... I've noticed a strange behavior using my lisp... Have a look at these two videos, please... https://screenrec.com/share/WpTPbRfNjO and https://screenrec.com/share/Cpmc9aGvx0 and try to explain this error... It happens, no matter if i enter all the other coordinates manually and as integers, obviously... if i use trim and snap to pick a point on the end of this arc i get the error... pay attention to command line in videos, input is manual and integers. And, it happens no matter what... try it for yourself. I find it a bit strange... I mean... really?! PS: I updated my lisp to use default Pi ...should have nothing to do with this, but here it is... HelR.lsp Edited October 11 by ibach Quote
ibach Posted October 11 Posted October 11 (edited) I like this!!! I like the rest of it too. Here is the dwg... Irm1.dwg The 20° angle is a bit off... If only i knew how to calculate it... i'll try... and probably fail a few times in the process... Edited October 11 by ibach Quote
ibach Posted October 11 Posted October 11 (edited) I promised the file size analysis... the same shape produced by my method took 49.2 KB (50,413 bytes) on disk in autocad18 format dwg when completely purged... the shape created by Irms cookbook took 53.0 KB (54,295 bytes)... and saved as dxf 18 mine took 183 KB (188,293 bytes) Irms 184 KB (188,896 bytes) ... Irm... I am still in wow with your solution... weight of CV 2 to 0.707 ... where did it come from exactly? 20° is arbitrary number, i see that and gives me a headache too... Wish you all a good night! PS: How do i manipulate CV 4 in lisp... one more headache too Edited October 11 by ibach Quote
fuccaro Posted October 11 Posted October 11 On 10/5/2014 at 9:15 PM, GP_ said: The code is not so nice but, for my use, it seems to work. Ciao HelixAlongPath.LSP 7.25 kB · 172 downloads I found this ancient thread: https://www.cadtutor.net/forum/topic/20-telephone-cord/ Almost 20 years ago I drew phone cords. These days I use wireless. Unfortunately the image from my first post is missing... 1 Quote
ibach Posted October 11 Posted October 11 (edited) I've seen your helix along path solution long long time ago. Thank you for the link. Impressive work. Just around that time I discovered Lee Mac site that thought me all i know about lisp... Thanks Lee... Few days latter I was able to draw a map with every light pole in the country with all the specifications from excel during the time that took a waiter to bring a morning coffee... Edited October 11 by ibach Quote
lrm Posted October 11 Posted October 11 @ibach Quote .. Irm... I am still in wow with your solution... weight of CV 2 to 0.707 ... where did it come from exactly? 20° is arbitrary number, i see that and gives me a headache too... Wish you all a good night! PS: How do i manipulate CV 4 in lisp... one more headache too Check this link for where the 0.707 comes from. It's the weight of a CV for a NURBS (sqrt(2)/2). https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/NURBS/RB-circles.html I wrote the following lisp to determine the needed twist angle. The input is 3 points as noted. (defun c:TwistAng (/ p1 p2 p3 ) (setq p1 (getpoint "\nEnter point at start of edge. ") p2 (getpoint p1 "Enter point at other end of edge: ") p3 (getpoint p1 "Enter point on plane of end but not on same edge: " ) ) (setq a (unitv (mapcar '- p2 p1)) b (unitv (mapcar '- p3 p1)) p (mapcar '+ p1 '(0 0 1)) da (dot (mapcar '- p p1) a) pa (mapcar '+ (mapcar '* a (list da da da))) db (dot (mapcar '- p p1) b) pb (mapcar '+ (mapcar '* b (list db db db))) pab (mapcar '+ p1 pa pb) ) (setq v (unitv (mapcar '- pab p1)) ang (acos (dot a v)) angdeg (- 90 (/ (* ang 180.) pi)) ) (princ "\nTwist angle is: ") (princ angdeg) (princ) ) (defun unitV (v / d) (setq d (distance '(0 0 0) v) d (mapcar '/ v (list d d d)) ) ) ;; ArcCosine - Lee Mac ;; Args: -1 <= x <= 1 (defun acos ( x ) (if (<= -1.0 x 1.0) (atan (sqrt (- 1.0 (* x x))) x) ) ) ; dot product of vectors a and b (defun dot (a b / dd) (setq dd (mapcar '* a b)) (setq dd (+ (nth 0 dd) (nth 1 dd) (nth 2 dd))) );end of dot An easy way to edit the values of a CV (e.g., CV 4) is to use the properties panel. I don't have time to explain right now but sometimes I use the following LISP to create cross sections (that are defined by blcks) along a spline. This approach allows the independent rotation of sections that are then used by the LOFT command. It provides much better twist control than SWEEP. (defun C:test (/ nsec blockname twist tottwist path inc n osm par der1 der2 p p1 p2 vy vz vx p3) ; draft version ; Adds blocks along a spline. The user specifies the number of blocks and ; the total amount of twist over the length of the spline. The Z axis of the block ; is tangent to the spline. ; LRM 5/1/2023 revised 6/4/2024 (command "ucs" "w") (setvar 'osmode 0) (setq nsec (getint "\nEnter number of sections: ")) (setq nsec (- nsec 1)) (setq blockname (getstring "\nEnter block name: ")) (setq twist (getreal "\nEnter start twist angle: ")) (setq tottwist (getreal "\nENter total twist start to end: ")) (setq path (car (entsel)) inc (/ (vlax-curve-getEndParam path) nsec) n 0 osm (getvar 'osmode) ) (setvar "cmdecho" 0) (repeat (+ nsec 1) (setq par (* inc n)) (setq der1 (vlax-curve-getfirstDeriv path par) der2 (vlax-curve-getSecondDeriv path par) p (vlax-curve-getPointAtParam path par) ) (setq p1 (mapcar '+ p (unitv (cross der1 der2)))) (setq p2 (mapcar '+ p (unitv der1))) (setq vy (unitv (mapcar '- p1 p))) (setq vz (unitv (mapcar '- p2 p))) (setq vx (unitv (cross vy vz))) (setq p3 (mapcar '- p vx)) (command "_point" "_non" p) (command "_point" "_non" p2) (command "_point" "_non" p3) (command "-insert" blockname '(0 0 0) 1 1 0) ;;; (command "_align" "last" "" '(0 0 0) p '(1 0 0) p1 '(0 0 -1) p2 "n") (command "_align" "last" "" '(0 0 0) p '(-1 0 0) p1 '(0 0 -1) p2 "n") (if (> (abs twist) 0.00001) (command "rotate3d" "last" "" "2" p p2 twist) ) (setq twist (- twist (/ tottwist nsec))) (setq n (1+ n)) ) ; end repeat (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)) ) ) I'm on the road for the weekend and will not be able to respond until next week. Lee Quote
ibach Posted October 11 Posted October 11 (edited) You just gave me enough to think for a week or two... Wish you a good voyage! Call me mad but I happen to be in the Andes at the moment... and again... you beet me to the question... tangent to the spline... the Z axis of the block ; is tangent to the spline that should do it... back to work... Edited October 12 by ibach Quote
lrm Posted October 12 Posted October 12 Andes? That's impressive! I'm enjoying the peak fall colors in the much smaller mountains of northern New Hampshire. Quote
ibach Posted October 12 Posted October 12 http://lispexpert.blogspot.com/p/chapter-13-3d-objects.html just some interesting reading... Quote
lrm Posted October 15 Posted October 15 @ibach your drawing has several solid ramps. They all look like reasonable solutions although some may not have the beginning and end slopes you want. What changes, if any, do you wan to make? Quote
ibach Posted October 16 Posted October 16 (edited) I am only looking for most "regular" solution... easy to describe, for example - this one, a vertical cross section is always a rectangle of same dimensions... its thickness is irregular though... for the thickness to be regular i would need to rotate the curve under a bit...(clockwise in this case... and it would give me a strange detail at the upper end under the horizontal slab that i do not want) - the white one i got sweeping the rectangle is not keeping the rectangle parallel to the ground nor the vertical crossection is always the same... - the thicken method should be the solution, but it has the same problem as the above (its upper surface has no hump though and the upper side of the section rectangle is always parallel to the ground, lower surface has a deviation for it has to compensate for the thickens to be the same...) ... I am still looking for the result i really like the most and the method fast enough and easy enough and that describes easy enough to continue assembling some kind of a ramp drawing lisp aid... Those are the possibilities i found to be giving some kind of acceptable result. None of which is actually perfect... The first one does give me the easiest calculation latter on... (idealization of static model is easy) PS: the result of sweep command confuses me a bit... that hump simply should not be there... we are sweeping around spline, not the helix though... i guess it is for that approximation but i'd love to hear educated explanation. Here is a 45° vertical section detail... the section rectangle in white and yellow case obviously does not follow the circular rotation of the top view rotating around its own vertical axes too and changing its width as it does so... Edited October 16 by ibach Quote
ibach Posted October 16 Posted October 16 (edited) The actual shape i want should never have a hump in the upper surface, should never have a cross section height and the thickness smaller than the height of the horizontal slabs and should compensate for the detail in lover curves connecting the slabs to be in the right position without breaking continuity.... Something like this; Edited October 16 by ibach 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.