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

    How to get real position of vertex

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 329 Views 2 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.
    • C Offline
      curator
      last edited by

      Hi there,

      I have problems understanding the data structure of SketchUp. Lets assume I have a empty scene and draw a simple rectangle. Then I can use ruby console like this

      
      Sketchup.active_model.entities.at(4).vertices.at(1).position
      Point3d(0, 3.93701, 0)
      
      

      Ok. Then I resize the rectangle using the scale tool (holding CTRL) by some factor and get
      different values

      
      Sketchup.active_model.entities.at(4).vertices.at(1).position
      Point3d(0.984252, 2.95276, 0)
      
      

      Ok, undo the rescaling and put the rectangle to a group. Then the call is

      
      Sketchup.active_model.entities.at(0).entities.at(1).vertices.at(0).position
      Point3d(0, 3.93701, 0)
      
      

      Then I rescale as above, but this time the group. I again try

      
      Sketchup.active_model.entities.at(0).entities.at(1).vertices.at(0).position
      Point3d(0, 3.93701, 0)
      
      

      The thing is, that the position of the vertex has changed in the scene, but the output as above does not change. How can I get the "real" position instead?

      kind regards,
      curator

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Get the "container[s]" of the entities, get their "transformation[s]", then transform the vertex's point to match.
        Then you'll have the point in the model coordinate system, not the point in the container's coordinates system...
        This will give you the path through the nesting:
        http://www.sketchup.com/intl/en/developer/docs/ourdoc/model#active_path
        See these methods to get the 'accumulated' transformations of each container:
        http://www.sketchup.com/intl/en/developer/docs/ourdoc/transformation

        TIG

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

        Advertisement