Simple stacking blocks problem

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
ColoradoChris
Posts: 2
Joined: Tue Oct 16, 2018 1:34 pm

Simple stacking blocks problem

Post by ColoradoChris »

Hi all,
I have what I think should be a simple application but I am not finding answers to my simple question.

First I am using FreeCAD 0.17.

We participate in a dog sport called Barnhunt, which involves dogs looking through structures constructed of straw bales for rats that are safely contained in PVC tubes.

Part of the fun and challenge of the sport is that the course is different each time. The judges design the courses and usually they get build by other people. Some judges give you a drawing on a napkin in crayon, others at least use graph paper and some even use sketchup. I was hoping FreeCAD would be a better solution than all the others.

I am trying to construct a "part" that is a hay bale. 18" x 36" x14" and use it to construct a stack of bales. There are also boards 36"x24"x.75" and 36"x48"x.75" that we use to create roofs for tunnels through the bales. The bales (up to about 75) are stacked in a 24' x 24' area.

Some bales are flat, others laying on their sides and others leaning at various angles against each other.

The better courses "build" on each other so that as the class changes levels of difficulty (and thus the structure gets bigger) there is minimal rework and restacking, just the addition of more bales.

So my first question, is this a good use of FreeCAD, and the second, could someone point me in the right direction to get started. I was able to use the part feature to draw a cube representing a bale, but couldn't figure out how to duplicate it and stack it with other instances of the same part.

Thanks in advance,
--Chris
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Simple stacking blocks problem

Post by PrzemoF »

Welcome to the forum!!

You can take a look at the Voxel workbench:
https://www.youtube.com/watch?v=nE0LYK__R5U
https://forum.freecadweb.org/viewtopic.php?f=24&t=20013

P.S. Amazing sport!! :shock:
ColoradoChris
Posts: 2
Joined: Tue Oct 16, 2018 1:34 pm

Re: Simple stacking blocks problem

Post by ColoradoChris »

PrzemoF wrote: Tue Oct 16, 2018 2:13 pm Welcome to the forum!!

You can take a look at the Voxel workbench:
https://www.youtube.com/watch?v=nE0LYK__R5U
https://forum.freecadweb.org/viewtopic.php?f=24&t=20013

P.S. Amazing sport!! :shock:
thanks, i will look into it, but the quick review I did so far looks too symmetrical for what i need.

p.s. here is a video that shows some of the sport and also how the bales are stacked to help you see what i need to model. https://www.youtube.com/watch?v=3X5rCKkGQiA
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Simple stacking blocks problem

Post by TheMarkster »

You could do this with Part workbench. Create cubes to represent the boards and bales. I'd make one original of each, then duplicate them as I need new ones. You could layout a grid of Part points to serve as guides for the 24'x24' area. Make a Part point, then use Draft array to layout 17 of them 18 inches apart in both x and y directions. (Could also lay them out in the z direction if you want to.)

With 0.18 the Placement dialog can now move objects in the axial direction and rotate them about selected points. But the dragger tool in 0.17 can also be used here to advantage. I'd set the movement increment to 18 inches so each object can hopefully snap to one of the points in the grid.

With the 0.18 Placement task dialog you can select the points in the grid to serve as guides to where you want to move a bale or board. I'll make a video demonstrating this. After you open the placement dialog you need to check the apply incremental changes checkbox. To move your object to a desired location, click the desired point on the object, e.g. on lower left corner of bale, then click the destination point in the grid (I use blender navigation mode, which means I hold down Ctrl while clicking to select multiple objects). Next, with those 2 points selected, click the Selected points button (Shift+click Selected points button to copy the distance between the points to the clipboard). Then paste the distance into the Axial spinbox, and click Apply axial button to make the move.

Selecting 1 point, then Selected points button will put that point's coordinates into the center x,y,z boxes. You could then rotate about one of the major axes, X,Y, or Z using that selected point as the pivot point for the rotation.

Select 2 points, then Selected points button will create a normalized direction vector and place it into the Axis box. If you pressed Shift while clicking Selected points it also puts the distance between the points in the clipboard. Paste into Axial, then click Apply axial to make the move along the new direction vector.

Select 3 points, then Selected points button creates the new direction vector by calculating the plane that is defined by those 3 points, then making a direction vector that is normal (or perpendicular) to this plane. The first selected point is the pivot point for the rotation. The angle between the 2nd and 3rd points is copied to the clipboard (if Shift+click is used), which can be pasted into the Rotation box. Sometimes the angle is in the wrong direction and you need to add a minus (-) sign in front of the angle to get the desired rotation.

I made the video, but it's kinda longish --18 minutes -- and no talking. I need to make a proper video showing how to use the Placement dialog with audio.

phpBB [video]
Attachments
stacking hay.FCStd
(18.81 KiB) Downloaded 13 times
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Simple stacking blocks problem

Post by Kunda1 »

ColoradoChris wrote: Tue Oct 16, 2018 1:49 pm
I saw this Workbench on Github, not sure if it's complete but maybe it can serve your purposes?
https://github.com/vectronic/freecad-legify-macros
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Simple stacking blocks problem

Post by TheMarkster »

I came up with an idea for a macro that could also be useful not only for this project, but also in other general cases. Here's how it works, you first select the object to be copied, then you select points where you want the copies of the object to be placed. When you run the macro it makes copies and places them at those points. I made a couple copies of the points array, so now there are 3 layers. I did it this way to be able to set different colors for the points at each level, and also to be able to hide the layers individually. A selected point must be a vertex or one of the points on the grid. Unfortunately, you can't select the entire array and put an object at each point (unless you select each point one at a time).

I rotated copies of each of the boards and the bale 90 degrees so they can be copied already rotated as desired. Probably some need to be rotated 180 degrees to get more consistent placement on the grid. You could do some 45 degrees also if you like, including some rotations about the x or y axis.

Here is the code for the macro, which is by no means "polished". It would probably be worth your time to create a custom toolbar for this if you plan to use it. I add a short video showing how to do this, plus a short demo of the macro in action. One thing that definitely needs to be improved is the way custom toolbar shortcuts are made. Would be nice to be able to drag and drop to a custom toolbar.

Code: Select all

import FreeCAD
import Draft

sel = Gui.Selection.getSelectionEx()
if not sel:
    raise StandardError("Select object to copy first, then points to place copies at.")

if len(sel)<=1:
    raise StandardError("Not enough objects selected, select object first, then points to locate copies")

points=[]
for ii in range(0,len(sel)):
    if ii==0:
        obj = sel[ii].Object
    else:
        points.extend(sel[ii].PickedPoints)

for p in points:
    copy = Draft.makeCopy(obj)
    plm = copy.Placement
    plm.Base=p
    copy.Placement = plm
    pass
phpBB [video]
Attachments
HayStacker.FCMacro
(548 Bytes) Downloaded 15 times
stacking hay.FCStd
(23.02 KiB) Downloaded 16 times
Post Reply