• Login
sketchucation logo sketchucation
  • Login
ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

Two problems with an 'Export to Vue' ruby script

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 4 Posters 271 Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    Alex Jenyon
    last edited by 20 May 2009, 15:33

    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:

    404 Not Found

    favicon

    (www.highend3d.com)

    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
      end
    

    But this doesn't return the correct result. Does anyone know what I'm doing wrong?

    Many thanks for your time.

    AJ

    Concept artist / Matte painter
    www.aj-concepts.net

    1 Reply Last reply Reply Quote 0
    • S Offline
      solo
      last edited by 20 May 2009, 15:38

      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.

      http://www.solos-art.com

      If you see a toilet in your dreams do not use it.

      1 Reply Last reply Reply Quote 0
      • C Offline
        Chris Fullmer
        last edited by 20 May 2009, 15:41

        #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

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

        1 Reply Last reply Reply Quote 0
        • A Offline
          Alex Jenyon
          last edited by 20 May 2009, 15:45

          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...

          Concept artist / Matte painter
          www.aj-concepts.net

          1 Reply Last reply Reply Quote 0
          • C Offline
            Chris Fullmer
            last edited by 20 May 2009, 16:01

            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

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 20 May 2009, 16:27

              @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_mm to turn the SU units to mm. Look at the Numeric class for other conversions: http://code.google.com/apis/sketchup/docs/ourdoc/numeric.html

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • A Offline
                Alex Jenyon
                last edited by 21 May 2009, 11:09

                I've solved both problems now - please see my other thread for the finished plugin

                Concept artist / Matte painter
                www.aj-concepts.net

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                1 / 1
                • First post
                  6/7
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement