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

    How to get transformation.origin of a internal component

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 407 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.
    • romuloigorR Offline
      romuloigor
      last edited by

      We need to measure the [x,y,z] beetween the red’s circle’s marked in the picture.
      How we need to do that? We have 2 components, one inside another. We need to know how to measure the distance of the x,y,z axis of the inside red block to the zero ground of the model. But to do that, we CAN’T add the values of the big gray box and the values of the red block inside, because we’re going to have too many elements one inside another, and calculate all this can be slow and it’s not a good solution.

      http://us.media.gabster.com.br/Transformation.Origin_of_a_Internal_Componente.png

      ` Sketchup.active_model.entities.each{|ent|
      puts "BigBox #{ent.transformation.origin.to_s}" if ent.is_a?(Sketchup::ComponentInstance) }

      Sketchup.active_model.entities.each{ |ent|
      puts ent.definition.entities.each{ |e|
      puts "RedBox #{e.transformation.origin.to_s}" if e.is_a?(Sketchup::ComponentInstance)
      } if ent.is_a?(Sketchup::ComponentInstance) }`

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

        First find the insertion point of the Redbox instance in its current context.
        Next find the transformation of the Bigbox container instance.
        You need to get a handle on the 'Redbox'.
        Let's assume there is only one instance and that's inside Bigbox.
        redbox = model.definitions['Redbox'].instances[0]
        Now get its insertion point
        pt = redbox.transformation.origin
        Now let's assume there's only one instance of 'Bigbox'.
        bigbox = model.definitions['Bigbox'].instances[0]
        Get its transformation
        tr = bigbox.transformation
        Apply that to the point 'pt'
        pt.transform!(tr)
        The point 'pt' is now relative to the model's origin, NOT the Bigbox's internal origin...

        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