Skip to content

Instantly share code, notes, and snippets.

@JollyWizard
Created February 9, 2022 07:03
Show Gist options
  • Save JollyWizard/ace48ce52053da24e6dcdd471a21c85a to your computer and use it in GitHub Desktop.
Save JollyWizard/ace48ce52053da24e6dcdd471a21c85a to your computer and use it in GitHub Desktop.
AutoLisp getpoint and echo test (CorelCAD viability investigation.)
;| Set Variable |;
(setq p1 (getpoint))
;| CorelCAD Output |;
; (73.0 9.65125 0.0)
;| Point is interpretted as a bad function. It's a list with no command. |;
(p1)
;| CorelCAD Output |;
; Error: Invalid parameter.
;| Wrapping in a list helps, but is dirty |;
(list p1)
;| CorelCAD Output |;
; ((73.0 9.65125 0.0))
;| FlatMap into new list is clean. |;
(append p1)
;| CorelCAD Output |;
; (73.0 9.65125 0.0)
;| Use `eval` for indirect invocation. Probably cleanes syntax. |;
(eval 'p1)
;| CorelCAD Output |;
; (73.0 9.65125 0.0)
;| Use `progn` to evaluate and echo return value (last list item). Creates anonymous function block. |;
(progn (setq p1 (getpoint)) p1)
;| CorelCAD Output |;
; (47.88 25.39270337 0.0)
;| Akward Output from print functions |;
(print p1)
;| CorelCAD Output |;
; (73.0 9.65125 0.0) (73.0 9.65125 0.0)
; Why does this duplicate in Corel CAD? All prin{1,n,c} functions do this.
@JollyWizard
Copy link
Author

I have CorelCAD 2019 and wanted to try AutoLisp and see how compatible it was with online tutorials for AutoCad.

My target application would need to collect points, so I wanted to start with collecting and echoing the points.

I did not realize the echoing was going to be the hard part.

I was a complete AutoLisp newcomer, with no experience in a real Autocad environment. It took me a while to establish that the point was being saved in a global scope. This was because all methods I tried to echo the point were leading to it being evaluated improperly as a function call, or using incompatible features and commands.

Once I was able to get the coordinates printed, I worked my way backwards to a cleaner process and started to document my options.

This is the result of that session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment