Moment known(Nmm)"]
loads = [0.0, 0.0, 0.0]
results = inputbox prompts, loads, “Other Loads”
variable_load, permanent_load, moment = results
if (moment != 0)
@M = moment
else
uls = (1.35*variable_load + 1.5*permanent_load +
1.5weight)@length @M = 0.11uls@length @shear = 0.60 * uls
end
end
my @b = 280 and @h=300 from before… when i try to multiply the weight
it should come 2.1 but in this case it is 0.0032 or so… which is
wrong… hence because of that my uls values are wrong and hence the
entire following program… i am pretty sure its problem with the
variables… just cant figure out where!
my @b = 280 and @h=300 from before… when i try to multiply the weight
it should come 2.1 but in this case it is 0.0032 or so…
Then obviously @b and @h are not being set correctly.
which is
wrong… hence because of that my uls values are wrong and hence the
entire following program… i am pretty sure its problem with the
variables… just cant figure out where!
Well, what do your tests say?
BTW, your code is problematic. Two tips:
That’s a pretty long method. Refactor parts of it into shorter
methods if possible.
Never, never use Floats for arithmetic – they’re imprecise. Use
integers or BigDecimal.
That’s a pretty long method. Refactor parts of it into shorter
methods if possible.
Never, never use Floats for arithmetic – they’re imprecise. Use
integers or BigDecimal.
hi thanks for your tip i will certainly look into it!
I dont think the problem is with the @b or @h because when i output
these values within the code it seems to be fine! its quiet confusing…
but yes i will read through the book to make the shorter!
This calculation is correct: 2.1, so if you are getting a different
result it has to be that @b or @h don’t contain what you think they
do. Can you try to print @b, @h and weight, and show us the calling
code that produces weight being 0.00032?
def moment_calc
puts “@b is #{@b}”
puts “@h is #{@h}”
weight =((25.0*@b*@h) / 10**6)
puts “weight is #{weight}”
end
If you put this in your program, what happens?
Jesus.
actually since this is sketchup, i cannot output data in terms of
puts… i have to make a vcb messagebox or a UI messagebox, both of
which are visual outputs,
Also I am unable to use bigDecimal in the ruby script even when i put
“require ‘bigdecimal’” in the beginning it is not supported by it… but
you have to believe me it does come as 0.00032 as i saif and not 2.1!
its quiet frustrating…
This calculation is correct: 2.1, so if you are getting a different
result it has to be that @b or @h don’t contain what you think they
do. Can you try to print @b, @h and weight, and show us the calling
code that produces weight being 0.00032?
def moment_calc
puts “@b is #{@b}”
puts “@h is #{@h}”
weight =((25.0*@b*@h) / 10**6)
puts “weight is #{weight}”
end
in Ruby you don’t need to declare your variables before assigning
(another value) to them. So assigning them a 0 only to assign them
another value afterwards is not needed.
i believe i may have found the solutions… sketchup automatically
converts my numbers which is actually in mm and i was stupid enough to
put them as 280.mm which makes it numeric 280 mm and thus it becomes
11.8 inches, which is where i have been getting the 0.00032… i think
going here was the best thing i did today