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

    Rotation unexepected result

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 230 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.
    • 2 Offline
      2000apacman
      last edited by

      Hello, i would like to script a dragon curve so i first wrote this :

      ` mod = Sketchup.active_model # Open model
      ent = mod.entities # All entities in model
      sel = mod.selection # Current selection
      point1 = [0,0,0]
      point2 = [1,0,0]
      point3 = [1,1,0]
      group0 = Sketchup.active_model.entities.add_group
      line = group0.entities.add_line point1,point2
      line = group0.entities.add_line point2,point3

      t0 = Geom::Transformation.rotation( [1, 1, 0], [0,0,1], 90.degrees)
      group1 = group0.copy
      group1.transformation = t0

      group2=group0.parent.entities.add_group([group0, group1])

      t1 = Geom::Transformation.rotation( [2, 0, 0], [0,0,1], 90.degrees)
      group3 = group2.copy
      group3.transformation = t1

      group4=group2.parent.entities.add_group([group2, group3])

      t2 = Geom::Transformation.rotation( [2,-2,0], [0,0,1], 90.degrees)
      group5 = group4.copy
      group5.transformation = t2`

      But the thrird rotation gave me unexepected result. It seems to be a rotation and a translation.
      Why?

      1 Reply Last reply Reply Quote 0
      • 2 Offline
        2000apacman
        last edited by

        I found the correction myself.
        And I use:

        group1.transform!(t0)

        instead of:

        group1.transformation = t0

        But if someone can explain to me why this works with transform! but not with .transformation
        i would be thankful.

        1 Reply Last reply Reply Quote 0
        • jolranJ Offline
          jolran
          last edited by

          Transform! executes/calls the method wheras transformation = is assigning it.

          tested your code and
          transformation = , did give me a same result as transform!

          The principle still is call method with object.method.

          Oh, and to answer the question. In this case were dealing with Geom::Transformation object. So were not calling a method directly(I think..).So its more like

          Group.Geom::Transformation = myspecial.Geom::Transformation

          I hope I explained it correctly..

          If you test t0.class you will see it's a Geom::Transformation.object

          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