Beispiel #1
0
def test_sphere_cylinder_subtract():
    a = sphere(count=8, stacks=4, radius=0.5).translate(0.5, 0.5, 0.5)
    b = cylinder_2p(count=16,
                    base_center=(0, 0, 0),
                    top_center=(1, 0, 0),
                    radius=0.3)
    CSG(a) - CSG(b)
Beispiel #2
0
def test_bolt():
    shaft = cylinder_2p(count=32,
                        base_center=(0, 0, 0),
                        top_center=(1, 0, 0),
                        radius=0.1)
    head = cone_2p(base_center=(-0.12, 0, 0), apex=(0.1, 0, 0), radius=0.25)
    notch1 = cube().translate(-0.1, 0, 0).scale(0.02, 0.20, 0.02)
    notch2 = cube().translate(-0.1, 0, 0).scale(0.02, 0.02, 0.20)
    bolt = CSG(shaft) + CSG(head) - CSG(notch1) - CSG(notch2)
Beispiel #3
0
# Copyright (c) 2020, Manfred Moitzi
# License: MIT License
from pathlib import Path
import ezdxf
from ezdxf.addons.pycsg import CSG
from ezdxf.render.forms import cube, cylinder_2p

DIR = Path("~/Desktop/Outbox").expanduser()

cube1 = cube()
cylinder1 = cylinder_2p(count=32,
                        base_center=(0, -1, 0),
                        top_center=(0, 1, 0),
                        radius=0.25)

doc = ezdxf.new()
doc.set_modelspace_vport(6, center=(5, 0))
msp = doc.modelspace()

# build solid union
union = CSG(cube1) + CSG(cylinder1)
# convert to mesh and render mesh to modelspace
union.mesh().render_mesh(msp, dxfattribs={"color": 1})

# build solid difference
difference = CSG(cube1) - CSG(cylinder1)
# convert to mesh, translate mesh and render mesh to modelspace
difference.mesh().translate(1.5).render(msp, dxfattribs={"color": 3})

# build solid intersection
intersection = CSG(cube1) * CSG(cylinder1)