sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🚨 Skimp | 25% Off until March 30 Buy Now

    How to get transformation.origin of a internal component

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 506 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

        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 Login
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement