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!
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Model.edit_transform for parent

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 4 Posters 532 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.
    • C Offline
      cjthompson
      last edited by

      Is there any way to get the local transformation for a component that is not at the end of the active path?

      For example, say I double click a component, and then double click a component inside that one. I want to find the local transformation of the first.

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

        model.edit_transform gives the current edit's transformation
        To find the transformation of the 'first' parent you need to iterate down the tree until it's the one before 'model' - so something like...

        ### first you somehow set 'entities' to the current edit's entities set and find the parent e.g. 
        parent=entities[0].parent
        ### then
        done=false
        until done
          if parent.entities[0].parent == Sketchup.active_model
            done=true
          else
            parent=parent.entities[0].parent
          end#if
        end
        ### parent is now the first container ?
        ###
        

        TIG

        1 Reply Last reply Reply Quote 0
        • C Offline
          cjthompson
          last edited by

          I can get the instance I'm looking for, but I'm having problems getting the actual transformation, since it is also in edit mode, but not the current edit mode.

          I was able to find instance.local_transform, but it is undocumented.

          Basically, I'm trying to use an input point to iterate up the model to find the component's path, instead of drilling down to find it.

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

            instance.local_transformation seems to return nothing useful...
            Working down towards Model will give you the entity's ultimate container - then you can find its transformation ?
            If the final container is a component-definition then you're stuffed as you'll want the actual instances' transformation
            You can't easily get the transformation of an entity inside an Instance of a Definition - get the entity's transformation within the Definition and then adjust it by the containing Instance's transformation [and then that's container's transformation etc etc] so you should somehow be able to apply that to the entity's too ? πŸ˜•

            TIG

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              I would guess the local_transformation method has its origin as part of Dynamic Components. It's not mentioned in the API docs at all.

              Hi

              1 Reply Last reply Reply Quote 0
              • C Offline
                cjthompson
                last edited by

                It looks like its inherited from drawing element, so you can use it on faces and edges, too.

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  Model.active_path
                  http://code.google.com/apis/sketchup/docs/ourdoc/model.html#active_path

                  use that to traverse the path up to the current

                  model.edit_transform * model.active_path.last.transform.inverse
                  ❓

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

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    @cjthompson said:

                    Basically, I'm trying to use an input point to iterate up the model to find the component's path, instead of drilling down to find it.

                    Get help from a pickhelper?
                    http://code.google.com/apis/sketchup/docs/ourdoc/pickhelper.html

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

                    1 Reply Last reply Reply Quote 0
                    • C Offline
                      cjthompson
                      last edited by

                      @thomthom said:

                      @cjthompson said:

                      Basically, I'm trying to use an input point to iterate up the model to find the component's path, instead of drilling down to find it.

                      Get help from a pickhelper?
                      http://code.google.com/apis/sketchup/docs/ourdoc/pickhelper.html

                      except you can't pick outside of edit mode.

                      I solved it by just drilling down the model structure, instead of going up it like the original idea.

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        yes you can.
                        once you do a pick you get an array of various pick solutions.
                        .all_picked returns a list of all the top level entities for each possible path. .count return the number of possible paths. Use .path_at to get a drill down path for the given index.

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

                        1 Reply Last reply Reply Quote 0
                        • C Offline
                          cjthompson
                          last edited by

                          sorry, I must be really tired today. I meant you can't use a pickhelper outside of the current context. so If you you have two instances in the model, and you double click one, you can't use the pickhelper on it's sibling.

                          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