by nimitz 3 years, 4 months ago
1 times 3.59s avg. build time

Triangle from cylinders

for some reason radius = 5 causes problems

License: CreativeCommons-ShareAlike Publicly Listed: True Tags: None

Log in to download models or make your own copy!

Auto Apply Changes

  1. #
  2. # Important MetaData
  3. #
  4. UOM = "mm"
  5. #
  6. # PARAMETERS and PRESETS
  7. # These parameters can be manipulated by end users
  8. #
  9. length = FloatParam(min=1.0,max=500.0,presets={'default':100.0,'short':10.0},group="Basics", desc="Length the sides")
  10. radius = FloatParam(min=1.0,max=500.0,presets={'default':3.0,'short':10.0},group="Basics", desc="Edge Radius")
  11. #
  12. # Other Variables.
  13. # These are used in the script but not exposed to users to change with the GUI
  14. width = 40.0
  15. #
  16. # Your build method. It must return a solid object
  17. #
  18. def build():
  19. rad = radius.value
  20. radm = radius.value - 0.01
  21. len = length.value
  22. heig = math.sqrt(3)/2 * len
  23. bar1 = Workplane("XZ").workplane(0).transformed(rotate=Vector(30, 0, 0)).circle(rad).extrude(-len)
  24. bar2 = Workplane("XY").workplane(0).transformed(rotate=Vector(60, 0, 0)).circle(rad).extrude(-len)
  25. bar3 = Workplane("XZ").workplane(-heig).transformed(rotate=Vector(90, 0, 0)).circle(rad) \
  26. .extrude(-len/2)
  27. bar4 = Workplane("XZ").workplane(-heig).transformed(rotate=Vector(270, 0, 0)).circle(rad) \
  28. .extrude(-len/2)
  29. ball1 = Workplane("XY").workplane(-rad).circle(rad).extrude(rad*2,True).edges().fillet(radm)
  30. ball2 = Workplane("XY", origin=(0,heig,-len/2+radm)).circle(rad).extrude(-rad*2,True).edges().fillet(radm)
  31. ball3 = Workplane("XY", origin=(0,heig,len/2-radm)).circle(rad).extrude(rad*2,True).edges().fillet(radm)
  32. result = bar1.add(bar2).add(bar3).add(bar4).add(ball1).add(ball2).add(ball3).combine()
  33. return result