Skip to content

Instantly share code, notes, and snippets.

@JesusFreke
Created October 16, 2019 08:07
Show Gist options
  • Save JesusFreke/e4abf48a311f18b29bca6037711bace5 to your computer and use it in GitHub Desktop.
Save JesusFreke/e4abf48a311f18b29bca6037711bace5 to your computer and use it in GitHub Desktop.
Design for 45 degree elbow for shaper origin vacuum hose
# Copyright (c) 2019 Ben Gruver
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
This file is meant to be run as a Fusion 360 Script and requires the fscad add-in to be installed. See http://fscad.org
"""
import adsk.core, adsk.fusion
import time
from fscad import *
wall_thickness = 3
def design():
bottom = Cylinder(20, 36/2)
bottom_inner = Cylinder(bottom.height, bottom.radius - wall_thickness)
hollow_bottom = Difference(bottom, bottom_inner)
bottom_adapter = Cylinder(20, 34/2, bottom.radius)
bottom_adapter_inner = Cylinder(
bottom_adapter.height,
bottom_adapter.bottom_radius - wall_thickness,
bottom_adapter.top_radius - wall_thickness)
hollow_bottom_adapter = Difference(bottom_adapter, bottom_adapter_inner)
hollow_bottom_adapter.place(
~hollow_bottom_adapter == ~hollow_bottom,
~hollow_bottom_adapter == ~hollow_bottom,
+hollow_bottom_adapter == -hollow_bottom)
joint_tool = Box(100, 100, 100)
joint_tool.place(
+joint_tool == +hollow_bottom,
~joint_tool == ~hollow_bottom,
-joint_tool == -hollow_bottom)
joint_tool.add_named_point(
"rotation_center",
Point3D.create(
joint_tool.max().x,
joint_tool.mid().y,
joint_tool.min().z))
joint_tool.ry(22.5, center=joint_tool.named_point("rotation_center"))
jointed_bottom = Union(Difference(hollow_bottom, joint_tool), hollow_bottom_adapter)
bottom_jointed_face = jointed_bottom.find_faces(joint_tool)[0]
top_joint = Cylinder(20, bottom.radius)
top_joint_inner = Cylinder(top_joint.height, top_joint.radius - wall_thickness)
hollow_top_joint = Difference(top_joint, top_joint_inner)
hollow_top_joint.place(
~hollow_top_joint == ~hollow_bottom,
~hollow_top_joint == ~hollow_bottom,
+hollow_top_joint == +hollow_bottom)
joint_tool.place(
~joint_tool.named_point("rotation_center") == +hollow_top_joint,
~joint_tool.named_point("rotation_center") == ~hollow_top_joint,
~joint_tool.named_point("rotation_center") == -hollow_top_joint)
hollow_top_joint = Difference(hollow_top_joint, joint_tool)
top_jointed_face = hollow_top_joint.find_faces(joint_tool)[0]
hollow_top_joint.add_named_faces("jointed_face", top_jointed_face)
top_transition = Cylinder(10, 39/2, bottom.radius)
top_transition_inner = Cylinder(
top_transition.height,
top_transition.bottom_radius - wall_thickness,
top_transition.top_radius - wall_thickness)
hollow_top_transition = Difference(top_transition, top_transition_inner)
hollow_top_transition.place(
~hollow_top_transition == ~hollow_top_joint,
~hollow_top_transition == ~hollow_top_joint,
+hollow_top_transition == -hollow_top_joint)
top_hose_acceptor = Cylinder(20, 42/2, 39/2)
top_hose_acceptor_inner = Cylinder(
top_hose_acceptor.height,
top_hose_acceptor.bottom_radius - wall_thickness,
top_hose_acceptor.top_radius - wall_thickness)
hollow_top_hose_acceptor = Difference(top_hose_acceptor, top_hose_acceptor_inner)
hollow_top_hose_acceptor.place(
~hollow_top_hose_acceptor == ~hollow_top_transition,
~hollow_top_hose_acceptor == ~hollow_top_transition,
+hollow_top_hose_acceptor == -hollow_top_transition)
top = Union(hollow_top_joint, hollow_top_transition, hollow_top_hose_acceptor)
top.rz(180)
top.ry(45 + 180)
top_jointed_face = hollow_top_joint.named_faces("jointed_face")[0]
top.place(
~top_jointed_face == ~bottom_jointed_face,
~top_jointed_face == ~bottom_jointed_face,
~top_jointed_face == ~bottom_jointed_face)
assembly = Union(jointed_bottom, top)
assembly.create_occurrence(scale=.1)
def run(_):
start = time.time()
run_design(design, message_box_on_error=False, document_name=__name__)
end = time.time()
print(end-start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment