Ruby: 3d align components
-
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:
- some custom components, axis at each bottom left corner.
- 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

-
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..
-
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.
-
@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
-
@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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement