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

    Question about "open" groups.

    Scheduled Pinned Locked Moved Developers' Forum
    22 Posts 5 Posters 1.8k Views 5 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
      CPhillips
      last edited by

      Ok, now I can detect that it is open. But how can I tell what the unopened groups transform is. As soon as a group is opened its transform becomes identity. I even tried to get it in a observer and by the time the onOpen is called it is already transformed.

      1 Reply Last reply Reply Quote 0
      • T Offline
        todd burch
        last edited by

        Post a small script that illustrates what you are having trouble with.

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

          @unknownuser said:

          Post a small script that illustrates what you are having trouble with.

          Create a group and select it. Then type:

          group=Sketchup.active_model.selection[0]
          Then:
          group.transformation.to_a.inspect

          Note the transformation.

          Now open the group and execute the same line.
          group.transformation.to_a.inspect

          When open the transformation will always be:
          [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]

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

            But the Group's transformation stays the same even if its entities are changed... so what's the point trying to get something you already know? Sorry if I'm missing the obvious.

            Hi

            1 Reply Last reply Reply Quote 0
            • T Offline
              todd burch
              last edited by

              OK, you're right.

              What are you trying to do? Can you use the group's transformation origin and apply that to any translation you need to do for your cpoints?

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

                @unknownuser said:

                OK, you're right.

                What are you trying to do? Can you use the group's transformation origin and apply that to any translation you need to do for your cpoints?

                I could if I could get the original transformation. But as I said its set to identity as soon as you open the group.

                When I create the group of construction points I set an attribute that has its initial position in the group. Then the user opens the group, manipulates the points and I compare the new position to the position stored in the attribute. It works fine if the group is closed but if it is still open the points are transformed into world space instead of group space so I am comparing apples and oranges.

                @jim said:

                But the Group's transformation stays the same even if its entities are changed... so what's the point trying to get something you already know? Sorry if I'm missing the obvious.

                The groups transform does not stay the same. Not only is the transform zeroed but the location of all the points is world relative instead of group relative. If I have a point at position (1,1,1) in a group when I open the group its position will be (1,1,1) + whatever the transformation.origin of the unopened group is. Not to mention the effects of rotation and scaling.

                It seems when you open a group Sketchup transforms all the entities in that group by the groups transform and then sets the group transform to identity.

                1 Reply Last reply Reply Quote 0
                • T Offline
                  todd burch
                  last edited by

                  I had a similar issue recently and I simply had to tell the user that the operation he was trying to perform was not allowed while in Group edit. This was because of the bugs dealing with working with groups and being out of context when in group/component edit.

                  That's the way the ball bounces.

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

                    @unknownuser said:

                    I had a similar issue recently and I simply had to tell the user that the operation he was trying to perform was not allowed while in Group edit. This was because of the bugs dealing with working with groups and being out of context when in group/component edit.

                    That's the way the ball bounces.

                    Thats disappointing.

                    Thanks Todd.

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

                      I found a work around but its a little gross. I don't fully trust observers not to crash Sketchup.

                      I put a entityObserver on my lattice group and then in onChangeEntity I store the current transformation in an attribute. Then when a user moves a point I check to see if the group is open (via observer) and if so I transform my control points by the inverse of the stored transform. That gives me a group relative point. whew.

                      Thanks for the help.
                      Chris

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        todd burch
                        last edited by

                        I figured it out!

                        If your group is open, get any entity in the group, and do this:

                        entity.parent.origin

                        That will give you the origin of the group's transformation. Viola!

                        Todd

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

                          @unknownuser said:

                          I figured it out!

                          If your group is open, get any entity in the group, and do this:

                          entity.parent.origin

                          That will give you the origin of the group's transformation. Viola!

                          Todd

                          When I try that the parent is ComponentDefinition and that doesn't have .origin. Did I miss a step?

                          Chris

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            todd burch
                            last edited by

                            Oops. Sorry.

                            entity.parent.insertion_point

                            Todd

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

                              @unknownuser said:

                              Oops. Sorry.

                              entity.parent.insertion_point

                              Todd

                              Ah! That does seem to work. Its only a point though, any way to get the rest of the transformation?

                              Thanks Todd!

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                todd burch
                                last edited by

                                My hat of guessing says...

                                tr = Geom::Transformation.new(entity.parent.insertion_point)

                                Todd

                                1 Reply Last reply Reply Quote 0
                                • T Offline
                                  todd burch
                                  last edited by

                                  ...but I don't think that will take care of any rotation. 😞

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

                                    @unknownuser said:

                                    ...but I don't think that will take care of any rotation. 😞

                                    Yeah without rotation it doesn't help. But the observer method seems to be working fine so far.

                                    Chris

                                    1 Reply Last reply Reply Quote 0
                                    • T Offline
                                      todd burch
                                      last edited by

                                      I did check with Google on this topic yesterday, and they see it as a flaw.

                                      Todd

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

                                      Advertisement