Question about "open" groups.
-
You can tell if you are in Group or Component edit by comparing Sketchup.active_model.entities to Sketchup.active_model.active_entities. If they are the same, you are not in Group/Comp edit.
Todd
-
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.
-
Post a small script that illustrates what you are having trouble with.
-
@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.inspectNote the transformation.
Now open the group and execute the same line.
group.transformation.to_a.inspectWhen 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] -
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.
-
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?
-
@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.
-
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.
-
@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.
-
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 -
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
-
@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
-
Oops. Sorry.
entity.parent.insertion_point
Todd
-
@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!
-
My hat of guessing says...
tr = Geom::Transformation.new(entity.parent.insertion_point)
Todd
-
...but I don't think that will take care of any rotation.
-
@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
-
I did check with Google on this topic yesterday, and they see it as a flaw.
Todd
Advertisement