Help!
-
I made this code in the Web Console
model = Sketchup.active_model entities = model.active_entities selection = model.selection if selection.empty? UI.messagebox("No Selection") else prompts = ["X", "Y", "Z"] defaults = ["1.0", "1.0", "1.0"] list = ["", "", ""] input = UI.inputbox prompts, defaults, list, "Size" group = entities.add_group selection if (group) selection.add group else UI.messagebox "Failure" end Xsize = input[0].to_f Ysize = input[1].to_f Zsize = input[2].to_f e = selection[0] tr1 = e.transformation tr2 = Geom;;Transformation.scaling(Xsize, Ysize, Zsize) e.transform!(tr1.inverse) e.transform!(tr2) e.transform!(tr1) status = group.explode endBut, every time I run the script, I get this message in the ruby console:
warning; already initialized constant Xsize warning; already initialized constant Ysize warning; already initialized constant ZsizeHow do I fix this?
-
@unknownuser said:
> Xsize = input[0].to_f > Ysize = input[1].to_f > Zsize = input[2].to_f >But, every time I run the script, I get this message in the ruby console:
> warning; already initialized constant Xsize > warning; already initialized constant Ysize > warning; already initialized constant Zsize >How do I fix this?
Well, for start, you could type in lowercase
Because if your variable name starts with capital letter, ruby takes it as CONSTANT. You are lucky that ruby lets to redefine constants, most of programming languages don't allow
. This is why you get the warning.
use something like this, it's easier to read and those are local variables, not constants:x_size = input[0].to_f y_size = input[1].to_f z_size = input[2].to_f -
@unknownuser said:
Well, for start, you could type in lowercase
Because if your variable name starts with capital letter, ruby takes it as CONSTANT. You are lucky that ruby lets to redefine constants, most of programming languages don't allow
. This is why you get the warning.
use something like this, it's easier to read and those are local variables, not constants:> x_size = input[0].to_f > y_size = input[1].to_f > z_size = input[2].to_f >Thanks! it works perfectly now!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement