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

    Geom::Transformation.rotation

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 793 Views 3 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
      confitex architure
      last edited by

      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.

      1. I insert component in 0,0,0 (transform)
      2. I rotate it (transform2)
      3. 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
      
      1 Reply Last reply Reply Quote 0
      • T Offline
        todd burch
        last edited by

        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

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

          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.

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

            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=transform2
            
            

            Hope this will help others.

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

              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

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

                @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)

                Hi

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

                  Not realy clear for me yet.
                  If I understand well, that means "transformation" is usefull for add_instance (f.e.) A kind of insert definition

                     transform1 = Geom;;Transformation.new inspoint
                     instance = entities.add_instance componentdefinition, transform1
                  
                  

                  and "transform!" to modify this instance.

                      instance.transform!(transform2)
                  
                  

                  But I'll get use to it. πŸ˜„
                  Thanks both of you for your help.

                  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