Jump to content

Lisp program to paste to multiple reference point inside cad.


Recommended Posts

Posted (edited)

I want to create an AutoLISP file that can paste objects to multiple reference points within a CAD file.

I have a sample generated by GPT that works, but the problem is that I have to hardcode the reference point inside the LISP code every time.

I need to modify it so that I can define the base point manually within CAD instead.

See the reference and suggest the solution

(defun c:PASTEPOINT ( / choice basept)

;; Define your reference points for each floor

;; Replace the coordinates with your actual base points

(setq basement '(0 0 0))

(setq ground '(1000 0 0))

(setq first '(2000 0 0))

;; Ask user which floor to paste into

(setq choice

(strcase

(getstring "\nPaste to which floor? [Basement/Ground/First]: ")

)

)

;; Select base point based on user choice

(cond

((= choice "BASEMENT") (setq basept basement))

((= choice "GROUND") (setq basept ground))

((= choice "FIRST") (setq basept first))

(T (progn

(prompt "\nInvalid option. Use Basement, Ground, or First.")

(exit)

)

)

)

;; Execute paste command at selected base point

(command "_.PASTECLIP" basept)

(princ)

)

 

Edited by SLW210
Added Code Tags!!
Posted

Please use Code Tags (not Quote Tags) for your code. (<> in the editor toolbar)

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