too few arguments

too few arguments

Anonymous
Not applicable
1,672 Views
7 Replies
Message 1 of 8

too few arguments

Anonymous
Not applicable

I've been attempting to debut this routine with vlide but i can't seem to figure it out I'm pretty sure the problem lies within the nested If statement

(if you see any other problems don't hesitate to mention them)

thanks

0 Likes
Accepted solutions (1)
1,673 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

This line is invalid:

 

(defun c:sgrill(gsize)

 

because C: command definitions are not supposed to have arguments -- 'gsize is a variable, and should be after a slash and a space.  If something is defined with arguments [things in parentheses after the function name but without a slash before them], then that's a function definition rather than a command definition, and it needs to be supplied with a value for the argument when it's used, and called for in parentheses with the function name and the argument(s).   You could do:

 

(defun sgrill (gsize); without the C:

 

but you would have to use it this way [for a 12" one]:

 

(sgrill 12)

 

This line is also invalid:

 

(while (/= gsize (or 6 8 10 12 14 16))

 

The (/=) function requires numerical or string inputs, but that (or) function is just going to return T.

 

But I suspect that's not really what you want to check for, i.e. presumably you don't want a value of, say, 13.  I would suggest:

 

(while (not (member gsize '(6 8 10 12 14 16)))

 

But here's a suggested different approach.  If you use the (initget)/(getkword) combination, it will accept only specified answers, and ask again until it gets an acceptable one.  So you don't need the (while) or (alert) parts.  And, it will have the answer as a text string, which you can paste into the Block name, without having to spell out an Insertion for each different size.  [Also, you don't need the .dwg filetype ending -- that's the only kind of file it will use.]  The whole thing could be something like:

 

(defun c:sgrill (/ gsize)

  (initget 1 "6 8 10 12 14 16"); [1 = no Enter allowed]

  (setq gsize (getkword "Supply grill size [6/8/10/12/14/16]: "))

  (command "_.insert" (strcat "SG" gsize))

  (princ)

)

Kent Cooper, AIA
Message 3 of 8

Anonymous
Not applicable

what is the 1 for in initget?

0 Likes
Message 4 of 8

Anonymous
Not applicable

also is that ' supposed to be there (i tried with and without it and it doesn't work either way

0 Likes
Message 5 of 8

Ranjit_Singh
Advisor
Advisor

I am calling it as below and it works

Command: (c:sgrill 6)
What size supply grill would you like (i.e. 6)? : 8
Insert Enter block name or [?]: __HATCH_006 Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]: Please Select an Insertion Point:
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: What size supply grill would you like (i.e. 6)? :
What size supply grill would you like (i.e. 6)? : 8
Insert of __HATCH_006
X2D corner point, or option keyword.
; error: Function cancelled
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>:
Specify rotation angle <0>:

Had to substitute the dwg name so it could go through. Also note the change on Alert function

 

Message 6 of 8

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

also is that ' supposed to be there (i tried with and without it and it doesn't work either way


That's appropriate for a list like that, but the problem is more about the function-vs.-command style definition with arguments-vs.-variables format of the (defun) line.  If you haven't yet, re-read Post 2, which I Edited some more while you were Posting this.

Kent Cooper, AIA
Message 7 of 8

Anonymous
Not applicable

thanks i was a little confused but that makes sense im still pretty new to lsp so the mistakes are everywhere 

0 Likes
Message 8 of 8

Kent1Cooper
Consultant
Consultant

@Ranjit_Singh wrote:

I am calling it as below and it works

Command: (c:sgrill 6)
What size supply grill would you like (i.e. 6)? : 8
....

....


That does something, but I wouldn't say it "works"....  I've seen other instances where calling a C:-prefixed command name in parentheses like that, with an argument supplied, is at least "accepted" without error, even though theoretically it's not "supposed" to be done that way.  But in this case, the supplied value would need to be checked, and if it's a valid one, I think the intent is that it should not ask what size the User wants, since it's been told already.  So it would take more of a change than just a different way of calling the command.  It might be made to bypass that question and go right to Inserting with a change in the (while) function's test structure [such as involving a (member) function, as initially suggested in Post 2], and maybe it would "work" that way [I haven't tried it], but the (initget)/(getkword) approach still seems better.

Kent Cooper, AIA