Skip to content

This application demonstrates how to use CadQuery, a parametric 3D CAD modelling framework based on the Open CASCADE Technology (OCCT) geometry kernel, in VIKTOR.

License

Notifications You must be signed in to change notification settings

viktor-platform/cadquery-opencascade-parametric-model

Repository files navigation

3D parametric modeling using CadQuery / Open CASCADE Technology (OCCT)

This application demonstrates how to use CadQuery, a parametric 3D CAD modelling framework based on the Open CASCADE Technology (OCCT) geometry kernel, in VIKTOR.

The primary objective of this app is to showcase VIKTOR's ability to handle complex geometries alongside those created with its native geometry module. This is accomplished by integrating an open-source Python library, CadQuery, which enables the creation of parametric 3D CAD models and their export in high-quality CAD formats such as STEP, AMF, 3MF, and GLTF.

Key functionalities featured in this app include:

  • Advanced parametric 3D modeling
  • Enhanced visualization through VIKTOR's Geometry and Image views

Parametric pillow block

In this template we will see how to view and edit a parametric pillow block for a standard 608-size ball bearing: 3D CAD model Parameters like height, width and bearing diameter in combination with CadQuery's python bindings for OpenCascade modelling are used in generate_assembly() to construct a parametric 3D model like so

# obtain parametrization fields
(length, height, bearing_diam, thickness, padding) = (
    params.length,
    params.height,
    params.bearing_diam,
    params.thickness,
    params.padding,
)

body = (
    cq.Workplane("XY")
    .box(length, height, thickness)
    .faces(">Z")
    .workplane()
    .hole(bearing_diam)
    .faces(">Z")
    .workplane()
    .rect(length - padding, height - padding, forConstruction=True)
    .vertices()
    .cboreHole(2.4, 4.4, 2.1)
    .edges("|Z")
    .fillet(params.fillet)
)

The assembly is then exported using one of CadQuery's many export functions to a format that VIKTOR's GeometryView can display in get_geometry_view()

assy, _ = generate_assembly(params)
glb = File()  # temporary file to store 3D model as gltf data
cq.occ_impl.exporters.assembly.exportGLTF(assy, glb.source, True)
return GeometryResult(geometry=glb)

About

This application demonstrates how to use CadQuery, a parametric 3D CAD modelling framework based on the Open CASCADE Technology (OCCT) geometry kernel, in VIKTOR.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages