Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All,
Precursor: I have very limited knowledge in lisp and how to debug lisp code.
I was able to use the new ChatGPT implementation on the OpenAI website to write the lisp code below:
;;; c:EQUALSPACE - Spaces a group of blocks evenly by a specified distance
;;;
;;; Usage:
;;; 1. Start the AutoCAD program and open a drawing.
;;; 2. Type "APPLOAD" on the command line and press Enter.
;;; 3. In the "Load/Unload Applications" dialog box, select "EQUALSPACE.LSP"
;;; from the list and click the "Load" button.
;;; 4. Type "EQUALSPACE" on the command line and press Enter.
;;; 5. Follow the prompts to select the blocks and specify the distance.
(defun c:EQUALSPACE()
"Spaces a group of blocks evenly by a specified distance"
;; Ask the user to select the blocks
(if (not (setq blocks (entsel "Select blocks: ")))
(princ "Oops! No blocks were selected. Try again.")
;; Ask the user to enter the distance
(if (setq distance (getreal "Enter the distance to space the blocks: "))
;; Check that at least two blocks were selected
(if (< (setq num_blocks (length blocks)) 2)
(princ "Oops! You need to select at least two blocks. Try again.")
;; Calculate the total distance and the starting point
(setq total_distance (* distance (- num_blocks 1)))
(setq start_point (car (car blocks)))
;; Iterate over the blocks and move them to the appropriate locations
(setq current_point start_point)
(foreach block blocks
(setq current_point (polar current_point (cadr block) total_distance))
(command "move" block "" start_point (car current_point) (cadr current_point) 0)
)
(princ "EQUALSPACE completed successfully.")
)
)
)
)
)
However, I am getting the errors below before I could even test if the lisp works in practice.
These are the errors:
Regenerating model.
AutoCAD menu utilities loaded.*Cancel*
Command:
Command:
Command:
Command: AP
APPLOAD EQUAL_SPACE.lsp successfully loaded.
Command: ; error: syntax error
Command:
Command: EQUALSPACE
Unknown command "EQUALSPACE". Press F1 for help.
Any ideas why? Please explain like I am five years old.
Solved! Go to Solution.