Two problems with an 'Export to Vue' ruby script
-
I've been working on a ruby script to take a SketchUP camera into 'Vue'. It's heavily based on Grant Marshall's 'camera2modo' ruby, and it's ALMOST working.
However, I've come across a couple of issues I'm trying to solve, and my head is just about fried. The information may well be around, but if it is, it's not in a form I'm currently capable of understanding
- so your time / patience is appreciated!Problem #1:
camscript.puts("cam.SetPosition(" + vx.to_s + ", " + vy.to_s + ", " + vz.to_s + ")")outputs something that looks like this:
cam.SetPosition( 5.44m, -7.92m, 9.85m)I would like it to output this, WITHOUT the units:
cam.SetPosition( 5.44, -7.92, 9.85)I thought that 'to_f' would be the correct command, but that doesn't seem to work... Any ideas on how I could do this?
Problem #2:
I need to calculate the 'roll' (i.e. z-axis rotation) of the camera.
I've found a tutorial on highend3d on how to do this:
And I'm pretty sure that in Ruby, (rather than MEL) it should look like this:
# Calculate Y-rotation of camera (roll) globaly = [0, 1, 0] normal = zaxis.cross globaly projection = normal.cross zaxis cosine_roll = up.dot projection ry = Math.acos(cosine_roll).radians if (upy < 0) ry = -ry endBut this doesn't return the correct result. Does anyone know what I'm doing wrong?
Many thanks for your time.
AJ
-
Alex I cannot help with the coding as I'm useless at such things but I would like to add my support and urge any of our code wizards to look into this as being a dedicated Vue user, such a facillity would be most welcome and very needed.
I'm very happy someone (you) is doing an effort in making this feature possible. -
#1 try this:
camscript.puts("cam.SetPosition(" + vx..to_f.to_s + ", " + vy.to_f.to_s + ", " + vz.to_f.to_s + ")")
You were right thinking you wanted .to_f, but it still has to end up being a string. So keep the .to_s on the end also.
I'll have to think about #2. Maybe someone else will come up with the answer faster,
Chris
-
Thanks Chris...
It's currently working perfectly for SketchUP scenes in which the camera isn't rotated in the z-axis (i.e. rolled / dutch tilted), and is above ground level.
You also have to enter the camera 'field of view' by hand once you're in Vue.
That's why I haven't posted it up yet - super user-unfriendly!
If I can solve these two problems with Ruby, and the 'FoV' issue with Python, SketchUP and Vue are ready to go.
AJ
EDIT: I've just got problem#1 to work, using .to_f.to_m.to_s - your script still produced a value in inches. Thanks for the pointer, though...
-
Oh good! I never get unit stuff right on the first try. Glad you figured it out.
I'll keep thinking about the other issue.
Chris
-
@alex jenyon said:
EDIT: I've just got problem#1 to work, using .to_f.to_m.to_s - your script still produced a value in inches. Thanks for the pointer, though...
SU always works in inches internally. Use
.to_mmto turn the SU units to mm. Look at the Numeric class for other conversions: http://code.google.com/apis/sketchup/docs/ourdoc/numeric.html -
I've solved both problems now - please see my other thread for the finished plugin
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