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

    Transformation.axes problem

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 2 Posters 351 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.
    • T Offline
      trottolino
      last edited by

      Hello everyone.
      I need to display the drawving direction of all the edges of one or more curves in my draw.
      The observer must be able to check for any edge of the selected curves which is the first and the end point.
      I thought to do this by placing at the center of each edge a 3D arrow component oriented from first point to end point.

      This is the code of my script:

      @mycomponent is my 3D arrow component

      @mymodel.selection.each {|e|
      if( e.typename == "Edge" )
      @myedgeID = e.entityID
      @p1 = e.start.position
      @p2 = e.end.position
      @p0 = Geom::Point3d.linear_combination 0.5, @p1, 0.5, @p2
      @my_vector3d = @p1.vector_to (@p2)
      t = Geom::Transformation.axes @p0, @my_vector3d, @my_vector3d, @my_vector3d
      @my_comp_instance = @mymodel.active_entities.add_instance @mycomponent, t
      end
      }

      The problem is that all the arrow components are correctly created in the right direction, but it's size is null and
      almost invisible!

      What's wrong?

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        The axes all need to be different from eachother. Setting them all the same will squash your component like your seeing right now. So you need to figure out how to define the other 2 axes. I've got some thoughts on how to do it, but it all depends on what the geometry involved is. Is it just a simple arc that all lies on a single plane? OR is it always flat on the x,y plane? Got a picture of it?

        Chris

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Oh yeah, and the possibly easier way is with Transformation.new (point, zaxis).

          So your transformation would be:

          t = Geom::Transformation.new(@p0, @my_vector3d)

          That will insert you component with its origin onto the centerpoint of your edge. And it will rotate it so that its up axis is oriented with the line vector. I think that is a better transformation to use in this case.

          Chris

          EDIT: Yup I tested it with your code and it works well. Just replace your current transformation with the one I wrote and that should do the trick. Well, that assumes that your arrow component is built pointing upwards, because this will orient its blue axis to the line.

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

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

            Great, this works perfectly!
            Think that this method was under my eyes but I've never tried it.
            Thank you very much.

            And if I want to insert my component with a different scale, how do I combine multiple transformations?

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              I would insert it using the method above. Then I would create another transformation for the scale. Just a simple uniform scale:

              t = Geom::Transformation.scaling scale

              That should do the trick. Apply it to the component with

              @my_comp_instance.transform! t

              I'd be interested if anyone had a simple way to combine the two transformations before applying them separately though. I've little to no luck with that. I always do it in steps.

              Chris

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

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

                But this second transformation moves component from its origin @p0
                Did you notice?

                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  Sorry, try it with this version of transformation:

                  t = Geom;;Transformation.scaling point, scale
                  

                  Yours would look like:

                  t = Geom::Transformation.scaling @p0 scale
                  @my_comp_instance.transform! t

                  Does that solve it?

                  Chris

                  Lately you've been tan, suspicious for the winter.
                  All my Plugins I've written

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

                    Of course.
                    In the meantime I also found the right solution.

                    This Sketchup is very powerful when you found the correct sequence of commands script!
                    Thanks again.

                    I think for my project (some ambitious) I will still need your advice.
                    I hope that you are always online these days as then.

                    Bye

                    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