Jump to content

Leaderboard

  1. GLAVCVS

    GLAVCVS

    Community Member


    • Points

      4

    • Posts

      371


  2. Emmanuel Delay

    Emmanuel Delay

    Community Member


    • Points

      2

    • Posts

      521


  3. Saxlle

    Saxlle

    Community Member


    • Points

      1

    • Posts

      115


  4. marko_ribar

    marko_ribar

    Trusted Member


    • Points

      1

    • Posts

      2,096


Popular Content

Showing content with the highest reputation on 03/25/2025 in all areas

  1. A slightly more complete version. Maybe it will be useful to someone someday. (defun c:GLAVCVSfibo (/ n cierraOtro p1 p2 p3 p4 i osmant cja f1 f2) (defun cierraOtro (f1 f2 / d ang) (setq d (+ f1 f2) ang (angle p2 p3) ) (command "_pline" (setq p1 p3) (setq p2 (polar p3 ang d)) (setq p3 (polar p2 (- ang i) d)) (setq p4 (polar p3 (- ang i i) d)) (polar p4 (- ang PI i) d) "") (command "_arc" "c" p4 p3 p1) (ssadd (entlast) cja) ) (setq n (getint "\nFibonaciCAD: Specifies number of sequences: ")) (setq f1 0 f2 1 i (/ PI 2) osmant (getvar "osmode")) (setvar "osmode" 0) (command "_pline" (setq p1 '(0 0)) (setq p2 '(-1 0)) (setq p3 '(-1 1)) (setq p4 '(0 1)) '(0 0) "") (command "_arc" "c" p4 p3 p1 "") (setq cja (ssadd)) (ssadd (entlast) cja) (repeat (- n 1) (cierraOtro f1 f2) (setq f f2 f2 (+ f1 f2) f1 f) ) (command "_pedit" "_m" cja "" "" "_j" 0 "") (setvar "osmode" osmant) (princ) )
    1 point
  2. @Nikon You should keep one thing in mind: the actual number of iterations will be 1 more than you specify. I forgot to consider the first one, which is done before the loop. Therefore, you should change 'repeat n' to 'repeat (- n 1)'
    1 point
  3. Oh wait... Here's a script I wrote 15 years ago ; ; Fibonacci spiral ; (defun fib () (princ "\nThis command draws a Fibonacci spiral. On my computer the max number of lines is a bit less than 50") (setq number_of_lines (getint "\nDraw a Fibonacci spiral.\nHow many sides: ")) (setq insertPoint (list 0 0)) (setq previousInsertPoint (list 0 0)) (setq twoPointsBack (list 0 0)) (setq key 1) (repeat number_of_lines (progn ; length of the line (setq newLength (fibonacci key)) ; the newest line is drawn +90° of the previous line (setq remainder (rem key 4) ) (setq angle (* remainder (/ PI 2.0)) ) ; draw the line. Retrieve the secondary point (that point will be the insert point of the next line) (setq secondaryPoint (drawNewLine insertPoint angle newLength )) ; ARC (setq radius (distance previousInsertPoint insertPoint)) (setq center twoPointsBack) (setq start_angle (* (- remainder 1) (/ PI 2.0)) ) (setq end_angle angle) (entmake (entmake_arc center radius start_angle end_angle) ; listed properties of an arc. ready to entmake ) ;; prepare variables for new iteration (setq oldLength newLength) (setq twoPointsBack previousInsertPoint) (setq previousInsertPoint insertPoint) (setq insertPoint secondaryPoint) (setq key (+ 1 key) ) ) ) (princ) ) (defun drawNewLine (insertPoint angle distance / secondaryPoint) (setq secondaryPoint (polar insertPoint angle distance)) (entmake (mapcar 'cons (list 0 100 8 62 100 10 11) (list "LINE" "AcDbEntity" "0" 3 "AcDbLine" insertPoint secondaryPoint) ) ) secondaryPoint ) (defun fibonacci (index / new_value) (setq new_value nil) ; New value. Each value (except the first two) is the sum of two previous values. results in: 1 1 2 3 5 8 13 21 ... (setq val_a 1) ; 1 value back (setq val_b 1) ; 2 values back (if (= index 0) (progn ) ) (if (= index 1) (progn (setq new_value 1) ) ) (if (= index 2) (progn (setq new_value 1) ) ) (if (> index 2) (progn (setq i 0) (repeat (- index 2) (progn (setq new_value (+ val_a val_b)) ; preapre for new iteration (setq val_a val_b) (setq val_b new_value) ) ) ) ) new_value ) (defun entmake_arc (Center Radius start_angle end_angle / opts) (setq opts (mapcar 'cons (list 0 100 100 10 40 210 100 50 51) (list "ARC" "AcDbEntity" "AcDbCircle" Center Radius '(0 0 1) "AcDbArc" start_angle end_angle ) ) ) ;(std-%entmake-template elist opts '(10 40 50 51)) opts ) (defun c:fib () (fib) )
    1 point
  4. You should change "pol" to "_pline"
    1 point
  5. Maybe something like this? (defun c:GLAVCVSfibo (/ n cierraOtro p1 p2 p3 p4) (defun cierraOtro (f1 f2) (setq d (+ f1 f2) ang (angle p2 p3) ) (command "pol" p3 (setq p2 (polar p3 ang d)) (setq p3 (polar p2 (- ang i) d)) (setq p4 (polar p3 (- ang i i) d)) (polar p4 (- ang PI i) d) "") ) (setq n (getint "\nFibonaciCAD: Specifies number of sequences: ")) (setq f1 0 f2 1 i (/ PI 2)) (command "pol" '(0 0) (setq p2 '(-1 0)) (setq p3 '(-1 1)) '(0 1) '(0 0) "") (repeat n (setq f f2 f2 (+ f1 f2) f1 f) (cierraOtro f1 f2) ) (princ) )
    1 point
  6. Look for my attachments posted in this topic... (You have to be logged to download attached files...) Here is link : https://www.theswamp.org/index.php?topic=12813.255
    1 point
  7. EDIT: oh wait ... I got a mistake somewhere. It makes a spiral, but not the Fibonacci spiral exactly. (vl-load-com) ;; https://www.cadtutor.net/forum/topic/75640-arc-start-and-end-point-help/ ;; Arc Endpoints - Lee Mac ;; Returns the endpoints of an Arc expressed in WCS (defun LM:ArcEndpoints ( ent / cen nrm rad ) (setq ent (entget ent) nrm (cdr (assoc 210 ent)) cen (cdr (assoc 010 ent)) rad (cdr (assoc 040 ent)) ) (mapcar (function (lambda ( ang ) (trans (mapcar '+ cen (list (* rad (cos ang)) (* rad (sin ang)) 0.0)) nrm 0) ) ) (list (cdr (assoc 50 ent)) (cdr (assoc 51 ent))) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun drawArc (cen rad sAng eAng) (entmakex (list (cons 0 "ARC") (cons 10 cen) (cons 40 rad) (cons 50 sAng) (cons 51 eAng))) ) (defun deg2rad (deg) (* pi (/ deg 180.0)) ) (defun c:Fibonacci ( / it ind arc fib fib_prev cen prev_cen rad sAng eAng endpts) (setq it (getint "\nHow many iterations (above 2 please): ")) ;; iteration 1 (setq ind 1) (setq fib_prev 1) (setq fib 1) (setq cen (list 0.0 0.0) rad 1.0 sAng 0 eAng (deg2rad 90) ) (setq arc (drawArc cen rad sAng eAng)) ;; iteration 2 (setq ind 2) (setq fib_prev 1) (setq fib 1) (setq cen (list 0.0 0.0) rad 1.0 sAng (deg2rad 90) eAng (deg2rad 180) ) (setq arc (drawArc cen rad sAng eAng)) ;; iteration 3 and further (while (<= ind it) (setq ind (+ ind 1)) (setq fib_prev fib) (setq fib (+ fib_prev fib)) (setq endpts (LM:ArcEndpoints arc)) (setq sAng eAng ;; start angle is the previous end angle eAng (+ eAng (deg2rad 90)) ;; end angle: add 90° cen (polar (nth 1 endpts) (+ eAng (deg2rad 90)) fib) ;; new center: endpoint of the previous arc; polar => 90° extra of endArc, dist of fibonacci length rad fib ) (setq arc (drawArc cen rad sAng eAng)) ) (princ) )
    1 point
  8. You're welcome . This part of code can be just an option/alternative to get a attribute position (it's not neccessery). (setq pt_attdef_one (polar pt 0.785 10) ;; 0.785 is the angle of 45 degree, 10 is the length (you can change the angle and length) pt_attdef_second (polar pt 5.497 10) ;; 5.497 is the angle of 315 degree, 10 is the length (you can change the angle and length) ) I think if both values nonzero 72 2 and 74 3, or 72 for e.g 1 and 74 0, or 72 for e.g 0 and 74 1, the text insertion point values are ignored. Really don't know... P.S. Bitno je da radi sada
    1 point
×
×
  • Create New...