Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Glass Wall - Bad Argument Type Fixnump: Value

4 REPLIES 4
Reply
Message 1 of 5
bennywise578
610 Views, 4 Replies

Glass Wall - Bad Argument Type Fixnump: Value

Firstly, I have been making a glass wall generator, and have been successful up til now. After the initial values have been given to each piece of glass within the wall, I want to distribute the "left over glass" from the last piece of glass to the preceding pieces of glass until all pieces of glass are within a 1/16" of each other. The code, though length and probably could be shortened a great deal, worked fine until I added this piece of code:

 

(setq inc2 (- bays 1))
(while (>= inc2 1)
(setq dif (- extra (ev2 "b0")))
(if (> dif 0.0625)
(set (var2 "b") (+ (ev2 "b0") 0.0625))
)
(setq inc2 (- inc2 1))
)

 

I've attached the entire routine and pointed out where this snippet of code is. When the routine is executed, I get the "Command: ; error: bad argument type: fixnump:" error. I know what this error means, but I just can't seem to figure this one out. Any help would be greatly appreciated.

Tags (2)
4 REPLIES 4
Message 2 of 5
Kent1Cooper
in reply to: bennywise578


@bennywise578 wrote:

.... I want to distribute the "left over glass" from the last piece of glass to the preceding pieces of glass until all pieces of glass are within a 1/16" of each other. The code...worked fine until I added this piece of code:

....

(if (> dif 0.0625)
(set (var2 "b") (+ (ev2 "b0") 0.0625))
)

....

When the routine is executed, I get the "Command: ; error: bad argument type: fixnump:" error.....


The 'fixnump' error is what you get when something that wants an integer argument is fed something else, like a real number, instead.  That suggests something like a (repeat) function, but not any of the functions in that excerpt.

 

But maybe that excerpt is changing the variety of number of a numerical variable that it works on, to pass the wrong kind to something further along.  Without digging deeply into the overall routine, I wonder whether this:

 

(set (var2 "b") (+ (ev2 "b0") 0.0625))

 

should be this instead:

 

(set (var2 "b0") (+ (ev2 "b0") 0.0625))
 
If the (var2 "b") variable is a number of bays, that's likely to be fed to something like (repeat), in which case if you've added decimal values to it, you'll get complaints.  But I suspect it's (var2 "b0") that you want to change until it comes within range.

 

And if that's the case, I think you need a (while) instead of that (if), so it keeps changing it until it comes within range -- as you have it, I think it will change it only once.

Kent Cooper, AIA
Message 3 of 5
bennywise578
in reply to: Kent1Cooper

Is there anyway you could further explain as to why adding decimals in would cause issues? I tried what you said and it still didn't work. I am currently re-thinking the entire approach to carry out this method, but I definitely think it's a decimal issue.

Message 4 of 5
Kent1Cooper
in reply to: bennywise578


@bennywise578 wrote:

Is there anyway you could further explain as to why adding decimals in would cause issues? I tried what you said and it still didn't work. ....


I hadn't dug very deeply into the overall routine, but was just assuming that the variable with (var2 "b") might be used for a number of bays or something.  But it looks like its value, taken by (ev2 "b"), is used only as part of a distance sum for (polar) functions, so it wouldn't matter if it was a real number rather than an integer.

 

But I still think

(set (var2 "b") (+ (ev2 "b0") 0.0625))

might want to be

(set (var2 "b0") (+ (ev2 "b0") 0.0625))

instead.

 

Don't you want to increase the existing value with the 0 in its variable name by 1/16 from its current value, until it gets big enough?  The code with the red b in it increases the variable without the 0 to 1/16 more than the value of the variable with the 0.   If it needs to do it more than once, it will keep increasing it to the same thing over and over, because what it's adding 1/16 to hasn't been changed in the meantime.  So it will never get to the target value and stop the loop.

 

But to answer your question about adding decimals causing issues, it's only if what you're adding them to is going to need to be an integer.  If I had been correct in assuming that the one with without the 0 was something like a number of bays, it could have been used in something like a (repeat) function.  But (repeat) can't repeat something 6.0625 times -- it needs an integer for the number-of-times argument, and if you give it a real number instead, you get just the error message that you described.  However, that's all moot in this case, if it's not used as I was assuming when I hadn't looked deeply enough.

Kent Cooper, AIA
Message 5 of 5
Anonymous
in reply to: bennywise578

Hi there.

 

Try replacing this line:

(setq inc2 (- bays 1))

with this

(setq inc2 (fix (- bays 1)))

 

It looks like since you're using (getdist) to set the value of bays, it's returning a real number, but the functions you're using to set variables require integers (the itoa function). Since you're setting inc2 off bays, inc2 is now a real number, which is fine for the while statement, but when you run into one of the variable functions, it bugs out.

 

Cheers.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost