Jump to content

How do I execute 2 commands in a LISP ( extrude and helix)


stapelbergp

Recommended Posts

Good day everyone.

 

I have only started with LISP programming a few hour ago. I want the following to happen with my LISP:

create a circle, extrude the circle

create a helix on the previous extrusion

delete the 1 solid from the other to create a screw thread.

 

I managed to create the circle and extrude it but I'm not sure how to start with the helix in the same LISP. and then the solid subtraction.

 

Any help would be appreciated.

 

here is the code that I have:

 


(defun c:circ()
(setq bp (getpoint "pick basepoint of circle:"))
 (setq rad (getint "enter radius of circle:"))
 

(command "circle" bp rad"")
 (command "extrude" "all")

 (setq hel (getpoint "pick basepoint of helix:"))
(setq rad1 (getint "enter radius of helix:"))
 (setq toprad (getint"enter top rarius of helix:"))
 (setq height (getpoint"specify height of helix:"))
 

 
 (command "helix" hel rad1 toprad height"")

 )

Edited by stapelbergp
Link to comment
Share on other sites

To get started...

 

(defun c:test ( / bp rad height cyl hel d p1 p2 p3 p4)
   (setq bp (getpoint "pick basepoint:"))
   (setq rad (getdist "\nenter radius:"))
   (setq height (getdist "specify height:"))
   (command "_cylinder" bp rad height)
   (setq cyl (entlast))
   (command "_helix" bp rad rad height)
   (setq hel (entlast))

   (setq d (* rad 0.1))
   (setq p1 (polar bp (* pi 0.25) d))
   (setq p2 (polar bp 0 (* d (sqrt 2.0))))
   (setq p3 (polar bp (* pi 1.75) d))
   (setq p4 (polar bp 0 (sqrt (/ (* d d) 2))))

   (command "_pline" "_non" bp "_non" p1 "_non" p2 "_non" p3 "_c")
   (setq square (entlast))
   (command "_sweep" square "" "_b" "_non" p4 hel)
   (setq thread (entlast))
   (command "_subtract" cyl "" thread "")
   (entdel hel)
   (entdel square)
   (princ)    
)

Link to comment
Share on other sites

Thanks for the help. Much appreciated!!!

Is there a way to give the user the option to select what shape is gonna be swept along the helix?

Edited by stapelbergp
Link to comment
Share on other sites

Here is my current code:

 

(defun c:circ ( / bp rad height cyl hel d p1 p2 p3 p4)
   (setq bp (getpoint "pick basepoint:"))
   (setq rad (getdist "\nenter radius:"))
   (setq height (getdist "specify height:"))
   (setq height1 (getdist "specify height:"))
   (setq turns (getdist "specify turns:"))
   
   (command "_cylinder" bp rad height)
   (setq cyl (entlast))
   (command "_helix" bp rad rad height1 turns)
   (setq hel (entlast))

 (setq d (* rad 0.1))
   (setq p1 (polar bp (* pi 0.25) d))
   (setq p2 (polar bp 0 (* d (sqrt 2.0))))
   (setq p3 (polar bp (* pi 1.75) d))
   (setq p4 (polar bp 0 (sqrt (/ (* d d) 2))))

   (command "_pline" "_non" bp "_non" p1 "_non" p2 "_non" p3 "_c")
   (setq square (entlast))
   (command "_sweep" square "" "_b" "_non" p4 hel)
   (setq thread (entlast))
   (command "_subtract" cyl "" thread "")
   (entdel hel)
   (entdel square)
   (princ)

  
)

Edited by stapelbergp
Link to comment
Share on other sites

Please use code tags the # sign in the menu above the text window when you are entering a post, makes it much easier for others to understand...

Link to comment
Share on other sites

Good evening all.

 

Can anyone assist me with my lisp code? how do I give the user the option to select the shape to be swept along the spiral? and how do I get it on the Z axis?

Link to comment
Share on other sites

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