• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Ruby: 3d align components

Scheduled Pinned Locked Moved Developers' Forum
5 Posts 3 Posters 381 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.
  • K Offline
    kaas
    last edited by 24 Jul 2014, 15:12

    I'm trying to make a plugin that array-copies components along a line in a chosen plane. It could be used to assist in filling sections with real line hatches. See image:

    1. some custom components, axis at each bottom left corner.
    2. choose component from list
      3a pick starting point, 3b pick end point, 3c pick point to set plane of component (and maybe later for scaling some components to fit between parallel lines)

    I'm no smart coder at all so have used quite some bits from TIG's mirror.rb. It works..a bit.. but with several vectors the rotation goes totally wrong (for instance 3abc in the middle). I hope someone can help me out a bit and point me into the right direction.

    
    def drawArray
       @bbox = @comp_copy.bounds #bounding box of chosen component
       @v1= @pos1.vector_to (@pos2) # vector between first and second picked point
       @copies = (@v1.length / @bbox.width).ceil # set number of copies
       @nv1 = @v1.length = @bbox.width #set spacing on vector = width of component
       @baseVector = Geom;;Vector3d.new 1,0,0 #base vector of component
       @baseNormal = Geom;;Vector3d.new 0,0,1 #base normal of component
       @deltaVect = (@baseVector.angle_between @v1).radians	#angle between base component and chosen path
       @plane = Geom.fit_plane_to_points(@ip1.position, @ip2.position, @ip3.position)
       @planeNormal = Geom;;Vector3d.new(@plane[0], @plane[1], @plane[2])
       @deltaNorm = (@baseNormal.angle_between @planeNormal).radians #angle between normal of component and normal of the 3 picked points
       @first=true
       while @copies > 0
       if @first 
          @translation = Geom;;Transformation.new(@pos1)
          @rotV = Geom;;Transformation.rotation(@pos1,@planeNormal,@deltaVect.degrees)
          @rotN = Geom;;Transformation.rotation(@pos1,@v1,@deltaNorm.degrees)
       else
          @v1.length = @bbox.width*@copies
          @translation = Geom;;Transformation.new(@pos1 + @v1) 
          @rotV = Geom;;Transformation.rotation(@pos1+@v1,@planeNormal,@deltaVect.degrees)
          @rotN = Geom;;Transformation.rotation(@pos1+@v1,@v1,@deltaNorm.degrees)
       end
       @componentinstance = @entities.add_instance(@comp_copy, @translation)
       @componentinstance.transform! (@rotV)
       @componentinstance.transform! (@rotN)
       @copies -= 1
       @first=false
    end
    @state=0
    end
    
    

    arrayCompAtLine.jpg

    1 Reply Last reply Reply Quote 0
    • J Offline
      jolran
      last edited by 24 Jul 2014, 17:30

      Do you want to make the plugin yourself or do you just need the functionality for you own use ?

      I have code for hatching faces with components that hasent made it into Hatchfaces yet..

      You can pm me if you like..

      1 Reply Last reply Reply Quote 0
      • S Offline
        sdmitch
        last edited by 24 Jul 2014, 20:46

        If you are willing to post or pm me a sample model and the plugin, I will be glad to see what if anything I can do with it.

        Otherwise I would use Geom::Transformation.axes.

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • K Offline
          kaas
          last edited by 25 Jul 2014, 05:54

          @sdmitch said:

          If you are willing to post or pm me a sample model and the plugin, I will be glad to see what if anything I can do with it.

          Hi Sdmitch, thanks for your offer. Jolran and I are already pm-ing about a solution so I think it will be already resolved.

          Max

          1 Reply Last reply Reply Quote 0
          • S Offline
            sdmitch
            last edited by 25 Jul 2014, 13:49

            @kaas said:

            @sdmitch said:

            If you are willing to post or pm me a sample model and the plugin, I will be glad to see what if anything I can do with it.

            Hi Sdmitch, thanks for your offer. Jolran and I are already pm-ing about a solution so I think it will be already resolved.

            Max

            Great, but the offer is still good.

            Nothing is worthless, it can always be used as a bad example.

            http://sdmitch.blogspot.com/

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              1/5
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement