Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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 ( [color=red]/[/color] cp)
...

Posted

Thank you both. I appreciate your explanation.:)

Posted

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

 

([color=BLUE]defun[/color] c:mci ( [color=BLUE]/[/color] cp zv )
   ([color=BLUE]setq[/color] zv ([color=BLUE]trans[/color] '(0.0 0.0 1.0) 1 0 [color=BLUE]t[/color])) [color=GREEN];; WCS Extrusion vector of UCS plane[/color]
   ([color=BLUE]if[/color] ([color=BLUE]setq[/color] cp ([color=BLUE]getpoint[/color] [color=MAROON]"\nCenter: "[/color])) [color=GREEN];; Center point in UCS[/color]
       ([color=BLUE]entmake[/color]
           ([color=BLUE]list[/color]
              '(00 . [color=MAROON]"CIRCLE"[/color]) [color=GREEN];; Entity Type[/color]
              '(62 . 5) [color=GREEN];; Colour[/color]
               ([color=BLUE]cons[/color] 10 ([color=BLUE]trans[/color] cp 1 zv)) [color=GREEN];; Center point in OCS[/color]
              '(40 . 2.0) [color=GREEN];; Radius[/color]
               ([color=BLUE]cons[/color] 210 zv) [color=GREEN];; Extrusion Vector in WCS[/color]
           )
       )
   )
   ([color=BLUE]princ[/color])
)

I have also ensured the program will perform correctly in all UCS construction planes.

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

 

([color=BLUE]defun[/color] c:mci ( [color=BLUE]/[/color] cp zv )
   ([color=BLUE]setq[/color] zv ([color=BLUE]trans[/color] '(0.0 0.0 1.0) 1 0 [color=BLUE]t[/color])) [color=GREEN];; WCS Extrusion vector of UCS plane[/color]
   ([color=BLUE]if[/color] ([color=BLUE]setq[/color] cp ([color=BLUE]getpoint[/color] [color=MAROON]"\nCenter: "[/color])) [color=GREEN];; Center point in UCS[/color]
       ([color=BLUE]entmake[/color]
           ([color=BLUE]list[/color]
              '(00 . [color=MAROON]"CIRCLE"[/color]) [color=GREEN];; Entity Type[/color]
              '(62 . 5) [color=GREEN];; Colour[/color]
               ([color=BLUE]cons[/color] 10 ([color=BLUE]trans[/color] cp 1 zv)) [color=GREEN];; Center point in OCS[/color]
              '(40 . 2.0) [color=GREEN];; Radius[/color]
               ([color=BLUE]cons[/color] 210 zv) [color=GREEN];; Extrusion Vector in WCS[/color]
           )
       )
   )
   ([color=BLUE]princ[/color])
)

I have also ensured the program will perform correctly in all UCS construction planes.

 

 

Lee, as always, efficient and master.

I appreciate that.

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