sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Hierarchy question

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 93 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
      Chelmite
      last edited by

      I'm trying to build up a hierarchical object in ruby/ketchup using nested groups, and components where appropriate.
      Most of the "add" operations seem to place things at the origin.
      To put things in the proper places, I've been creating them inside a group,
      then using the "transform_entities" method to translate and rotate the entities in the group.

      What's puzzling me is that when I apply transform_entities to the entities in the group, it works okay.
      The objects go where I want them to.
      I do something like create a few objects at the origin, rotate the group.entities to the desired orientation,
      then translate the group.entities away from the origin.
      Then, when I create a new (drawing) object inside the group, it doesn't appear at the origin. It appears at the translated origin that I thought was applied to each entity in the group. Why does the translation appear to be applied to new objects added to the group?

      Thanks for your help, or in directing me to the appropriate person/list.
      Chelmite

      (P.S. One of my first programming jobs was in 1972, programming transformation matrices for a robotic arm at the Stanford AI Lab, so I'm very familiar with graphics concepts, but not necessarily with how they are implemented in SketchUp.)


      The attached file draws an arrow, rotates and translates the entities in the group it's in, then draws another arrow, but the 2nd is rotated and translated.

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        @chelmite said:

        Why does the translation appear to be applied to new objects added to the group?

        Because the transformation is a property of the group (or component) instance, not the primitives within it's definition's entities collection, hence the origin is a property of the transformation.

        my_group_origin = my_group.transformation.origin()

        TIG has written extensively on transformation, you can go to his profile page, and click the link to search his posts. (Search this forum for 'transformation' yields 71 pages of hits !!)

        Also keep in mind that a Group is (internally,) a special kind of ComponentInstance, ie it has a ComponentDefinition (which appears it the model's DefintionList collection.)
        Meaning that group.entities, is similar to calling component_instance.definition.entities (if you were dealing with a component instance instead of a group.) The collection of primitives returned by group.entities, can also be accessed through the model's DefintionList collection. The reason for the group.entities shortcut method is that often groups are used as singleton definitions (ie, they often have only one instance, but can have many more than one.)

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          Edited the first paragraph of my reply (above,) to make it more clear that the entities collection, belongs to the ComponentDefinition, and not the instance (be they groups or components.)

          I'm not here much anymore.

          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