Geom::Transformation.rotation
-
Hello again,
I'm trying to explore how to insert and rotate an external component. But I can't figure out how geom::Transformation.rotate works...
I can't manage the rotation point... If I set inspoint at 0,0,0 and destpoint at 0,0,0 it works fine.
but if I change inspoint and destpoint it doesn't rotate the component around it.
So I tought I could do it in 3 steps.- I insert component in 0,0,0 (transform)
- I rotate it (transform2)
- I move to another point (transform3), but then the operation redefine the 2nd step and turn back to its originel orientation.
Any solution?
def insertrotate zaxis = Geom;;Vector3d.new(0,0,1) inspoint = Geom;;Point3d.new 0.cm,0.cm,0.cm destpoint = Geom;;Point3d.new 100.cm,100.cm,0.cm transform = Geom;;Transformation.new inspoint model = Sketchup.active_model entities = model.active_entities path = Sketchup.find_support_file "a_file.skp" ,"a_directory_under_sketchup_dir" definitions = model.definitions componentdefinition = definitions.load path instance = entities.add_instance componentdefinition, transform transform2 = Geom;;Transformation.rotation(inspoint,zaxis,90.degrees) transform3 = Geom;;Transformation.new destpoint UI.messagebox "Applying a new Transformation (in this case, a rotation)" status = instance.transformation=transform2 UI.messagebox "Applying a new Transformation (in this case, a move)" status = instance.transformation=transform3 end -
I can't look at this now, but if you don't get a solution before I do have time, I'll be happy to work it out for you.
I'm the rotation transformation king, you know.

Todd
-
Thanks Todd,
Glad I found the Geom::Transformation.rotate's key master.
It seems there's no other... I'll wait for your help
To all others:
if I don't get an answer on december 24th, feel free to help me, I'm sure King Todd will not be upset. -
I found it but do not really understand the reason why I must use .transform! instead of .transformation= ... (Todd?)
So to rotate around the perfect insertion point of the component, type:UI.messagebox "Applying a new Transformation (in this case, a rotation)" instance.transform!(transform2)instead of:
UI.messagebox "Applying a new Transformation (in this case, a rotation)" status = instance.transformation=transform2Hope this will help others.
-
Glad you worked it out.
I'll try to explain the difference between the two.
instance.transformation= is used to build a new transformation only. The return value is a transformation that can be applied to an object.
instance.transform! actually applies the transformation you pass; it doesn't just create a new definition of a transformation like the above does.
An analogy might be English terms. instance.transformation=, is the imperative to get a noun. instance.transform! is the imperative to perform the action - the verb if you will.
Ok, so maybe that analogy is poor and is completely incorrect in proper terms of English....

Todd
-
@unknownuser said:
Glad you worked it out.
I'll try to explain the difference between the two.
instance.transformation= is used to build a new transformation only. The return value is a transformation that can be applied to an object.
instance.transform! actually applies the transformation you pass; it doesn't just create a new definition of a transformation like the above does.
An analogy might be English terms. instance.transformation=, is the imperative to get a noun. instance.transform! is the imperative to perform the action - the verb if you will.
Ok, so maybe that analogy is poor and is completely incorrect in proper terms of English....

Todd
It's a pretty good analogy. I think of them as:
**transformation=**set the transformation (absolute)
tranform! apply the transformation (relative) -
Not realy clear for me yet.
If I understand well, that means "transformation" is usefull for add_instance (f.e.) A kind of insert definitiontransform1 = Geom;;Transformation.new inspoint instance = entities.add_instance componentdefinition, transform1and "transform!" to modify this instance.
instance.transform!(transform2)But I'll get use to it.

Thanks both of you for your help.
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 LoginAdvertisement