teknomatika 发表于 2022-7-6 06:34:55

entmake - why "too few argumen

Why "too few arguments"?
 

(defun c:mci (cp)(setq cp (getpoint "\nCenter point:"))(entmake       (list(cons 0 "CIRCLE");;Entity(cons 62 5);;Color(cons 10 cp);;Center point(cons 40 2);;Radius))(princ))

Tharwat 发表于 2022-7-6 06:50:52

(defun c:mci (/ cp)

marko_ribar 发表于 2022-7-6 06:55:50

You defined function as it requires argument (cp) and c:mci is defined as command function so you can't supply that argument, for as soon as you execute it in standard way like any other command with Command: mci, no argument is passed to function... So change line (defun c:mci (cp) to (defun c:mci ( / cp ) as like you've written later in function parameter cp is variable user supplies while function runs... So cp isn't argument but variable that needs to be localized...

MSasu 发表于 2022-7-6 07:06:35

I believe you were looking to localize the variables, not to have an argument (also, not valid for commands, only for functions):

(defun c:mci ( / cp)...

teknomatika 发表于 2022-7-6 07:13:25

Thank you both. I appreciate your explanation.

Lee Mac 发表于 2022-7-6 07:19:04

In addition to the above suggestions, you can also marginally improve the efficiency of your code by quoting expressions which need not be evaluated, e.g.:
 

(defun c:mci ( / cp zv )   (setq zv (trans '(0.0 0.0 1.0) 1 0 t)) ;; WCS Extrusion vector of UCS plane   (if (setq cp (getpoint "\nCenter: ")) ;; Center point in UCS       (entmake         (list            '(00 . "CIRCLE") ;; Entity Type            '(62 . 5) ;; Colour               (cons 10 (trans cp 1 zv)) ;; Center point in OCS            '(40 . 2.0) ;; Radius               (cons 210 zv) ;; Extrusion Vector in WCS         )       )   )   (princ))I have also ensured the program will perform correctly in all UCS construction planes.

teknomatika 发表于 2022-7-6 07:32:50

 
 
Lee, as always, efficient and master.
I appreciate that.

Lee Mac 发表于 2022-7-6 07:42:17

You're very welcome teknomatika.
页: [1]
查看完整版本: entmake - why "too few argumen