Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Stu142 committed Sep 10, 2024
2 parents 724063b + 08a8bc8 commit 0f7210c
Show file tree
Hide file tree
Showing 14 changed files with 304 additions and 24 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Select the Property view tab on the bottom right and change the values. Hit ente
- This Workbench has been verified as working on FreeCAD 0.21.1 and 0.21.2

# Changlog
**2024/09/10 Version 0.6.0**
- Added Bin Base generation
- Added custom independent x and y divider height parameter
- Move generation location to 0,0

**2024/04/28 Version 0.5.0**
- Added label shelf generation for parts bin: Center, Full Width, Left, Right
Expand Down
Binary file not shown.
Binary file modified freecad/gridfinity_workbench/__pycache__/commands.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file modified freecad/gridfinity_workbench/__pycache__/features.cpython-38.pyc
Binary file not shown.
Binary file modified freecad/gridfinity_workbench/__pycache__/init_gui.cpython-38.pyc
Binary file not shown.
Binary file modified freecad/gridfinity_workbench/__pycache__/version.cpython-38.pyc
Binary file not shown.
11 changes: 9 additions & 2 deletions freecad/gridfinity_workbench/commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import FreeCAD
import FreeCADGui as Gui
from .features import BinBlank, Baseplate, SimpleStorageBin, MagnetBaseplate, ScrewTogetherBaseplate, EcoBin, PartsBin
from .features import BinBlank, BinBase, Baseplate, SimpleStorageBin, MagnetBaseplate, ScrewTogetherBaseplate, EcoBin, PartsBin

class ViewProviderGridfinity(object):
def __init__(self, obj, icon_fn=None):
Expand Down Expand Up @@ -85,7 +85,14 @@ class CreateBinBlank(BaseCommand):
GRIDFINITY_FUNCTION = BinBlank
Pixmap = os.path.join(BaseCommand.ICONDIR, 'BinBlank.svg')
MenuText = 'Gridfinity Blank Bin'
ToolTip = 'Create a Gridfinity Blank bin'
ToolTip = 'Create a Gridfinity Blank Bin'

class CreateBinBase(BaseCommand):
NAME = "BinBase"
GRIDFINITY_FUNCTION = BinBase
Pixmap = os.path.join(BaseCommand.ICONDIR, 'BinBase.svg')
MenuText = 'Gridfinity Bin Base'
ToolTip = 'Create a Gridfinity Bin Base'

class CreateSimpleStorageBin(BaseCommand):
NAME = "SimpleStorageBin"
Expand Down
64 changes: 47 additions & 17 deletions freecad/gridfinity_workbench/feature_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,35 @@ def MakeLabelShelf(self, obj):
return funcfuse

def MakeScoop(self, obj):
V1 = App.Vector(obj.xTotalWidth-obj.BinUnit/2-obj.WallThickness, 0, -obj.UsableHeight + obj.ScoopRadius)
scooprad1 = obj.ScoopRadius+1*unitmm
scooprad2 = obj.ScoopRadius+1*unitmm
scooprad3 = obj.ScoopRadius+1*unitmm

xcomp_w = (obj.xTotalWidth-obj.WallThickness*2-obj.xDividers*obj.DividerThickness)/(obj.xDividers+1)

xdivscoop = obj.xDividerHeight - obj.HeightUnitValue

if obj.ScoopRadius > xdivscoop and obj.xDividerHeight != 0:
scooprad1 = xdivscoop-unitmm
if obj.ScoopRadius > xcomp_w and obj.xDividers > 0:
scooprad2 = xcomp_w-2*unitmm
if obj.ScoopRadius > obj.UsableHeight > 0:
scooprad3 = obj.UsableHeight

scooprad = min(obj.ScoopRadius,scooprad1,scooprad2,scooprad3)

if scooprad <= 0:
App.Console.PrintMessage("scooop could not be made due to bin selected parameters\n")
return

V1 = App.Vector(obj.xTotalWidth-obj.BinUnit/2-obj.WallThickness, 0, -obj.UsableHeight + scooprad)
V2 = App.Vector(obj.xTotalWidth-obj.BinUnit/2-obj.WallThickness, 0, -obj.UsableHeight)
V3 = App.Vector(obj.xTotalWidth-obj.BinUnit/2-obj.WallThickness - obj.ScoopRadius, 0, -obj.UsableHeight)
V3 = App.Vector(obj.xTotalWidth-obj.BinUnit/2-obj.WallThickness - scooprad, 0, -obj.UsableHeight)

L1 = Part.LineSegment(V1, V2)
L2 = Part.LineSegment(V2, V3)

VC1 = App.Vector(obj.xTotalWidth-obj.BinUnit/2-obj.WallThickness - obj.ScoopRadius + obj.ScoopRadius * math.sin(math.pi/4),0,-obj.UsableHeight + obj.ScoopRadius - obj.ScoopRadius * math.sin(math.pi/4))
VC1 = App.Vector(obj.xTotalWidth-obj.BinUnit/2-obj.WallThickness - scooprad + scooprad * math.sin(math.pi/4),0,-obj.UsableHeight + scooprad - scooprad * math.sin(math.pi/4))

C1 = Part.Arc(V1, VC1, V3)

Expand Down Expand Up @@ -382,8 +403,10 @@ def MakeStackingLip(self, obj):

def MakeCompartements(self, obj):

xdivheight = obj.xDividerHeight if obj.xDividerHeight !=0 else obj.TotalHeight
ydivheight = obj.yDividerHeight if obj.yDividerHeight !=0 else obj.TotalHeight

func_fuse= RoundedRectangleExtrude(obj.xTotalWidth-obj.WallThickness*2, obj.yTotalWidth-obj.WallThickness*2, -obj.TotalHeight+obj.HeightUnitValue, obj.TotalHeight-obj.HeightUnitValue, obj.BinOuterRadius-obj.WallThickness)
func_fuse= RoundedRectangleExtrude(obj.xTotalWidth-obj.WallThickness*2, obj.yTotalWidth-obj.WallThickness*2, -obj.UsableHeight, obj.UsableHeight, obj.BinOuterRadius-obj.WallThickness)
func_fuse.translate(App.Vector(obj.xTotalWidth/2-obj.BinUnit/2,obj.yTotalWidth/2-obj.BinUnit/2,0))

if obj.xDividers == 0 and obj.yDividers == 0:
Expand All @@ -403,30 +426,30 @@ def MakeCompartements(self, obj):
ycomp_w = (obj.yTotalWidth-obj.WallThickness*2-obj.yDividers*obj.DividerThickness)/(obj.yDividers+1)


xtranslate = zeromm + xcomp_w + obj.WallThickness
xtranslate = zeromm + xcomp_w + obj.WallThickness - obj.DividerThickness
ytranslate = zeromm + ycomp_w + obj.WallThickness

# dividers in x direction
for x in range(obj.xDividers):
comp = Part.makeBox(obj.DividerThickness,obj.yTotalWidth,obj.TotalHeight,App.Vector(-obj.BinUnit/2+obj.DividerThickness,-obj.BinUnit/2,0),App.Vector(0,0,-1))
comp = Part.makeBox(obj.DividerThickness,obj.yTotalWidth,xdivheight,App.Vector(-obj.BinUnit/2+obj.DividerThickness,-obj.BinUnit/2,-obj.TotalHeight),App.Vector(0,0,1))
comp.translate(App.Vector(xtranslate,0,0))
if x>0:
xdiv = xdiv.fuse(comp)

else:
xdiv = comp
xtranslate += xcomp_w+obj.DividerThickness
xtranslate += xcomp_w +obj.DividerThickness

# dividers in y direction
for y in range(obj.yDividers):
comp = Part.makeBox(obj.xTotalWidth,obj.DividerThickness,obj.TotalHeight,App.Vector(-obj.BinUnit/2+obj.xTotalWidth,-obj.BinUnit/2,0),App.Vector(0,0,-1))
comp = Part.makeBox(obj.xTotalWidth,obj.DividerThickness,ydivheight,App.Vector(-obj.BinUnit/2,-obj.BinUnit/2,-obj.TotalHeight),App.Vector(0,0,1))

comp.translate(App.Vector(0,ytranslate,0))
if y>0:
ydiv = ydiv.fuse(comp)
else:
ydiv = comp
ytranslate += ycomp_w+obj.DividerThickness
ytranslate += ycomp_w +obj.DividerThickness

if obj.xDividers > 0:
func_fuse = func_fuse.cut(xdiv)
Expand All @@ -437,7 +460,10 @@ def MakeCompartements(self, obj):
z0 = edge.Vertexes[0].Point.z
z1 = edge.Vertexes[1].Point.z

if z0 < 0 or z1 < 0:
if z0 != z1:
b_edges.append(edge)

if z0 <= -obj.UsableHeight and z1 <= -obj.UsableHeight:
b_edges.append(edge)

func_fuse = func_fuse.makeFillet(obj.InsideFilletRadius, b_edges)
Expand Down Expand Up @@ -860,13 +886,15 @@ def MakeEcoBinCut(self, obj):
xcomp_w = (obj.xTotalWidth-obj.WallThickness*2-obj.xDividers*obj.DividerThickness)/(obj.xDividers+1)
ycomp_w = (obj.yTotalWidth-obj.WallThickness*2-obj.yDividers*obj.DividerThickness)/(obj.yDividers+1)

xdivheight = obj.xDividerHeight if obj.xDividerHeight !=0 else obj.TotalHeight
ydivheight = obj.yDividerHeight if obj.yDividerHeight !=0 else obj.TotalHeight

xtranslate = zeromm + xcomp_w + obj.WallThickness
xtranslate = zeromm + xcomp_w + obj.WallThickness - obj.DividerThickness
ytranslate = zeromm + ycomp_w + obj.WallThickness

# dividers in x direction
for x in range(obj.xDividers):
comp = Part.makeBox(obj.DividerThickness,obj.yTotalWidth,obj.TotalHeight,App.Vector(-obj.BinUnit/2+obj.DividerThickness,-obj.BinUnit/2,0),App.Vector(0,0,-1))
comp = Part.makeBox(obj.DividerThickness,obj.yTotalWidth,xdivheight,App.Vector(-obj.BinUnit/2+obj.DividerThickness,-obj.BinUnit/2,-obj.TotalHeight),App.Vector(0,0,1))
comp.translate(App.Vector(xtranslate,0,0))
if x>0:
xdiv = xdiv.fuse(comp)
Expand All @@ -877,8 +905,7 @@ def MakeEcoBinCut(self, obj):

# dividers in y direction
for y in range(obj.yDividers):
comp = Part.makeBox(obj.xTotalWidth,obj.DividerThickness,obj.TotalHeight,App.Vector(-obj.BinUnit/2+obj.xTotalWidth,-obj.BinUnit/2,0),App.Vector(0,0,-1))

comp = Part.makeBox(obj.xTotalWidth,obj.DividerThickness,ydivheight,App.Vector(-obj.BinUnit/2,-obj.BinUnit/2,-obj.TotalHeight),App.Vector(0,0,1))
comp.translate(App.Vector(0,ytranslate,0))
if y>0:
ydiv = ydiv.fuse(comp)
Expand All @@ -891,13 +918,16 @@ def MakeEcoBinCut(self, obj):
if obj.yDividers > 0:
func_fuse = func_fuse.cut(ydiv)
b_edges = []

divfil = -obj.TotalHeight + obj.BaseProfileHeight + obj.BaseWallThickness + 1*unitmm
for idx_edge, edge in enumerate(func_fuse.Edges):
z0 = edge.Vertexes[0].Point.z
z1 = edge.Vertexes[1].Point.z

hdif = abs(z0-z1)
if hdif > 7:
b_edges.append(edge)
if z1 != z0:
if z1 >= divfil or z0 >= divfil:
b_edges.append(edge)

if obj.xDividers != 0 or obj.yDividers != 0:
func_fuse = func_fuse.makeFillet(obj.InsideFilletRadius, b_edges)

Expand Down
Loading

0 comments on commit 0f7210c

Please sign in to comment.