Shukoor Posted 6 hours ago Posted 6 hours ago (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 2 hours ago by SLW210 Added Code Tags!! Quote
SLW210 Posted 2 hours ago Posted 2 hours ago Please use Code Tags (not Quote Tags) for your code. (<> in the editor toolbar) Quote
Tsuky Posted 15 minutes ago Posted 15 minutes ago And simply with this, can be done? (defun c:PASTEPOINT ( / basept) ;; Define your reference points for each floor ;; Replace the coordinates with your actual base points (setq basept "Basement") (initget 9 "Basement Ground First") (while (not (listp basept)) (setq basept (getpoint (strcat "\nPaste to which floor? [Basement/Ground/First]<" basept ">: "))) (initget 9 "Basement Ground First") ) ;; Execute paste command at selected base point (command "_.PASTECLIP" "_none" basept) (prin1) ) 1 Quote
mhupp Posted 7 minutes ago Posted 7 minutes ago I'd be interested in what you prompted to get that code. GPT score 3/10 - missed localized variables - hard code points instead of getpoint - choice doesn't use getkword or use ucase (will only accept all caps input?) 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.