from jupytercad import CadDocument
doc = CadDocument()
doc.add_cone().add_sphere(radius=0.8).cut()
doc.objects
doc.add_cylinder(radius=0.5, position=[0, 0, 0.8]).fuse();
# Creating a gear wheel
from jupytercad import CadDocument
import math
doc = CadDocument()
radius = 5
num_teeth = 15
tooth_width = 0.5
# Create the gear wheel body
body_radius = radius - tooth_width / 2
body_height = tooth_width
doc.add_cylinder(radius=body_radius, height=body_height)
# Create the teeth
tooth_angle = 2 * math.pi / num_teeth
for i in range(num_teeth):
angle = i * tooth_angle
doc.add_box(
length=tooth_width,
width=tooth_width,
height=body_height,
position=[(radius - tooth_width) * math.cos(angle), (radius - tooth_width) * math.sin(angle), 0],
rotation_axis=[0, 0, 1],
rotation_angle=angle * 180/math.pi
).cut()
# Create the central hole
hole_radius = radius * 0.3
hole_height = body_height
doc.add_cylinder(radius=hole_radius, height=hole_height).cut()
doc
from jupytercad import CadDocument
doc = CadDocument("example3.FCStd")
doc
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox, BRepPrimAPI_MakeSphere, BRepPrimAPI_MakeCylinder
from OCC.Core.gp import gp_Pnt
from jupytercad import CadDocument
doc = CadDocument()
box_shape = BRepPrimAPI_MakeBox(10, 20, 30).Shape()
doc.add_occ_shape(box_shape)
doc
from OCC.Extend.DataExchange import read_stl_file
from OCC.Core.TopoDS import TopoDS_Shape
wheel = read_stl_file("fan.stl")
from jupytercad import CadDocument
doc = CadDocument()
doc.add_occ_shape(wheel)
doc
from OCC.Core.gp import gp_Pnt
from jupytercad_lab import CadDocument
doc = CadDocument('test.jcad')
doc
user= {'color':'#0000ff30', 'initials': 'BO','display_name': 'Bot'}
id = doc.add_annotation('box','Added from Python API', user=user)
doc.remove_annotation(id)
doc.set_color('box2', [0.5,0.4,0.2])
doc.set_color('box2',None)