Jump to content

Can anyone create a lisp for the golden ratio?


Recommended Posts

Posted

I don't know if anyone can do it, but here's what it needs to do:

 

I. Two choices in command hierarchy: golden [G], or reciprocal golden [R]

II. Drawing functions based on existing commands:

--A. 2-D operations:

----1. SNAP to point G or I

----2. DIVIDE an object into G number of segments or I number of segments

----3. LINE, PLINE, SPLINE, POLYGON, ARC, CIRCLE, ELLIPSE, etc. at lengths and angles G or I, with reference [R] option to properly ratio against another shape

----4. Polar Array option for angles from arc lengths g or I.

--B. 3-D operations:

----1. EXTRUDE: G or I option for height of extrusion; option for log spiral path; G or I options for angle of taper

----2. Predefined parameters to draw a log spiral by typing either SPIRAL or [LS]

----3. Anything else important or relevant that I haven't thought of? :)

III. Mode

--A. The command name for the lisp should just be GOLDEN

--B. All ACAD commands such as the ones above should work as normal, but with the added G, I, R, S,and LS options.

 

This would be a beautiful thing! I would very much appreciate any help in this regard. :D

Posted

Two very simple programs:

([color=BLUE]defun[/color] c:spiral ( [color=BLUE]/[/color] i l s x )
   ([color=BLUE]setq[/color] s 0.0
         i ([color=BLUE]/[/color] [color=BLUE]pi[/color] 25.0)
         x ([color=BLUE]exp[/color] ([color=BLUE]/[/color] ([color=BLUE]log[/color] ([color=BLUE]/[/color] ([color=BLUE]1+[/color] ([color=BLUE]sqrt[/color] 5)) 2)) [color=BLUE]pi[/color] 0.5))
   )
   ([color=BLUE]repeat[/color] 50
       ([color=BLUE]setq[/color] l ([color=BLUE]cons[/color] ([color=BLUE]list[/color] 10 ([color=BLUE]*[/color] ([color=BLUE]cos[/color] s) ([color=BLUE]expt[/color] x s)) ([color=BLUE]*[/color] ([color=BLUE]sin[/color] s) ([color=BLUE]expt[/color] x s))) l)
             s ([color=BLUE]+[/color] s i)
       )
   )
   ([color=BLUE]entmake[/color]
       ([color=BLUE]append[/color]
           ([color=BLUE]list[/color]
              '(0 . [color=MAROON]"LWPOLYLINE"[/color])
              '(100 . [color=MAROON]"AcDbEntity"[/color])
              '(100 . [color=MAROON]"AcDbPolyline"[/color])
              '(70 . 0)
               ([color=BLUE]cons[/color] 90 ([color=BLUE]length[/color] l))
           )
           l
       )
   )
   ([color=BLUE]command[/color] [color=MAROON]"_.zoom"[/color] [color=MAROON]"_E"[/color])
   ([color=BLUE]princ[/color])
)

 

 

([color=BLUE]defun[/color] c:3dspiral ( [color=BLUE]/[/color] c i n p s x )
   ([color=BLUE]setq[/color] s 0.0
         i ([color=BLUE]/[/color] [color=BLUE]pi[/color] 25.0)
         x ([color=BLUE]exp[/color] ([color=BLUE]/[/color] ([color=BLUE]log[/color] ([color=BLUE]/[/color] ([color=BLUE]1+[/color] ([color=BLUE]sqrt[/color] 5)) 2)) [color=BLUE]pi[/color] 0.5))
   )
   ([color=BLUE]entmake[/color] '((0 . [color=MAROON]"POLYLINE"[/color]) (70 . ))
   ([color=BLUE]repeat[/color] 50
       ([color=BLUE]entmake[/color]
           ([color=BLUE]list[/color]
              '(0 . [color=MAROON]"VERTEX"[/color])
              '(70 . 32)
               ([color=BLUE]list[/color] 10 ([color=BLUE]*[/color] ([color=BLUE]cos[/color] s) ([color=BLUE]expt[/color] x s)) ([color=BLUE]*[/color] ([color=BLUE]sin[/color] s) ([color=BLUE]expt[/color] x s)) s)
           )
       )
       ([color=BLUE]setq[/color] s ([color=BLUE]+[/color] s i))
   )
   ([color=BLUE]setq[/color] p ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 330 ([color=BLUE]entget[/color] ([color=BLUE]entmakex[/color] '((0 . [color=MAROON]"SEQEND"[/color]))))))
         n ([color=BLUE]mapcar[/color] '[color=BLUE]-[/color]
               ([color=BLUE]list[/color] ([color=BLUE]*[/color] ([color=BLUE]cos[/color] i) ([color=BLUE]expt[/color] x i)) ([color=BLUE]*[/color] ([color=BLUE]sin[/color] i) ([color=BLUE]expt[/color] x i)) i)
              '(1.0 0.0 0.0)
           )
   )
   ([color=BLUE]setq[/color] c
       ([color=BLUE]entmakex[/color]
           ([color=BLUE]list[/color]
              '(0 . [color=MAROON]"CIRCLE"[/color])
              '(40 . 0.2)
               ([color=BLUE]cons[/color] 10 ([color=BLUE]trans[/color] '(1.0 0.0 0.0) 0 n))
               ([color=BLUE]cons[/color] 210 n)
           )
       )
   )
   ([color=BLUE]command[/color] [color=MAROON]"_.extrude"[/color] c [color=MAROON]""[/color] [color=MAROON]"_P"[/color] p [color=MAROON]"_.zoom"[/color] [color=MAROON]"_E"[/color])
   ([color=BLUE]princ[/color])
)

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...