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

    Changing the orientation and position of the axis?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 278 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.
    • T Offline
      tpoz
      last edited by

      Hello all,
      I am writing a little program with a user interface that is supposed to draw rectangular openings on a face that is user specified (with constraints) but I have run into a bit of a snag.
      Here is the essence of my program:
      -the a user draws a rectangle, with the rectangle tool, and is 'allowed' to translate and rotate this rectangle in the x-y plane
      -based on the dimensions of the rectangle and some input for opening width and such, it is straightforward to define the four points of each opening...if the rectangle is just at the origin.
      I've tried to make a transformation to the axes using Geom::Transformation.axes origin, xaxis, yaxis, zaxis,
      but am unable to make these openings on the user's rectangle.
      I think part of the problem is that I am misinterpreting what transformation.axes really does. Does anyone have any input as to how I could do this or a better explanation of transformation.axes or anything really?!
      Thanks!
      laura
      p.s. if this is unclear, please, let me know 😄

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

        I've had problems with the transformation.axes, too. To the best of my knowledge, which isn't that good, it rotates the part so that the transformation axes are aligned to the global axes. As for a possible solution, I found it easiest to just do the math to adjust for the face.normal.

        1 Reply Last reply Reply Quote 0
        • Didier BurD Offline
          Didier Bur
          last edited by

          Hi Laura,

          Applying a transformation to geometry is available for groups and components.
          If your user rectangle is not a group or component, you'll have to retrieve what the user did exactly (translation, rotation) with its rectangle. That's not simple IMHO.
          If at first you make a group with the rectangle, then let the user translate/rotate it, it's really easy to draw openings in the rectangle because you can retrieve the group transformation and then draw your openings at origin and then apply the transformation to them, or each time you calculate a point of an opening boundary, apply the transformation to it:

          
          # Create the group;
          group=Sketchup.active_model.entities.add_group()
          # Draw the user rectangle here and let him translate/rotate it
          ...
          # get the group transformation;
          trans=group.transformation
          # Apply the transformation to a point of an opening;
          point.transform!(trans)
          # Explode the group if neede at the end of the draw;
          group.explode
          
          

          Hope this helps,

          DB

          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