Huh? Units? WTH?
-
So, I have this code:
def create_entities(data, container)
a = data["a"].to_l w = data["w"].to_l h = data["h"].to_l pts = [[0,0,0], [a,0,0], [a,w,0], [0,w,0], [0,0,0]] base = container.add_face ptsObviously, that's not the whole thing. It makes a box eventually, based on the points defined above.
Now, I want to alter the box to mae one side shorter than the other.
The default Length "a" is 1000mm. When I replace point [a,0,0] with [a-20,0,0] I get a weird result. I expect a-20 to be 980mm, but I end up with a side that is 492mm, which implies Sketchup is taking off 20 inches, not mm. How do I tell it to read all units as mm? I am using the Engineering (mm) template if that makes any difference.
Any help appreciated.
Regards,
Cathal
-
If '
a' is in mm and you usea-20you are taking of 20" !
Usea-20.mm
Raw numbers are assumed to be in inches ALWAYS! -
Make use of the Length class, and the extended method of String and Numberic to let SU handle the units. Remember that SU uses inches internally at all time. Units are presented to the user in the correct format using the assisting methods.
Length class: http://code.google.com/apis/sketchup/docs/ourdoc/length.html
Numeric class: http://code.google.com/apis/sketchup/docs/ourdoc/numeric.html
String class: http://code.google.com/apis/sketchup/docs/ourdoc/string.htmlKeep track of whether your object is a Float or Length - as that matters when the number is outputted as string to the user.
-
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
