### Clone examples repository Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/install.md.txt Download the public repository containing runnable example scripts. ```bash git clone https://github.com/MacCurdyLab/OpenVCAD-Public.git cd OpenVCAD-Public/examples ``` -------------------------------- ### Run a gradient example script Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/gradients.md.txt Execute a specific gradient script from the examples directory. ```bash python 01_linear_gradients.py ``` -------------------------------- ### Execute the attribute resolver example Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/attribute-resolver.md.txt Command to run the density-to-flow-rate conversion example script. ```bash python examples/3_attribute_resolver/03_resolver_density_to_flow_rate.py ``` -------------------------------- ### Run simulation compiler example Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/simulation-compiler.md.txt Command to execute the simulation compiler example script from the repository root. ```bash python examples/compilers/simulation/01_volume_fractions_export.py ``` -------------------------------- ### Run the attribute resolver example Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/attribute-resolver.md.txt Command to execute the Python script for the temperature to flow rate conversion example. ```bash python examples/3_attribute_resolver/02_resolver_temperature_to_flow_rate.py ``` -------------------------------- ### Run Metamaterial Attribute Example Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/metamaterials/attribute-modeling.md.txt Execute the provided example script within the project virtual environment to visualize different attribute arrangements. ```console ./.venv/bin/python examples/metamaterials/attribute_modeling/01_tpms_gradient_arrangements.py ``` -------------------------------- ### Run custom unit cell examples Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/metamaterials/custom-unit-cells.md.txt Execute the provided example scripts from the repository root to verify unit cell definitions. ```bash ./.venv/bin/python examples/metamaterials/custom_unit_cells/01_explicit_graph_cell.py ./.venv/bin/python examples/metamaterials/custom_unit_cells/02_programmed_graph_cell.py ./.venv/bin/python examples/metamaterials/custom_unit_cells/03_custom_implicit_cell.py ./.venv/bin/python examples/metamaterials/custom_unit_cells/04_conformal_custom_cells.py ``` -------------------------------- ### Install OpenVCAD Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/install.md.txt Upgrade pip and install the OpenVCAD package within the active virtual environment. ```bash python -m pip install --upgrade pip python -m pip install OpenVCAD ``` -------------------------------- ### pyvcad_rendering.render.Render Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/python-api/pyvcad_rendering/interactive.rst.txt Starts a wx-based user interface to inspect a design interactively. ```APIDOC ## pyvcad_rendering.render.Render ### Description Starts a wx-based user interface for inspecting a design interactively. ### Signature `pyvcad_rendering.render.Render()` ``` -------------------------------- ### Verify installation Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/install.md.txt Check the installed version of OpenVCAD to ensure the environment is configured correctly. ```python import pyvcad as pv print(pv.version()) ``` -------------------------------- ### Run the cross-compilation example Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/attribute-resolver.md.txt Execute the provided Python script to generate cross-compiled output files. ```bash python examples/3_attribute_resolver/04_cross_compilation_shore_hardness.py ``` -------------------------------- ### Install dependencies for gradient visualization Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/gradients.md.txt Install matplotlib and numpy to visualize gradient functions alongside 3D renders. ```bash pip install matplotlib numpy ``` -------------------------------- ### Initialize ExpressionConverter Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/attributes.html Examples demonstrating how to initialize an ExpressionConverter for single or multiple output attributes. ```python >>> conv = pv.ExpressionConverter( ... input_attributes=['temperature'], ... output_attributes=['flow_rate'], ... expressions=['20 * temperature + 100']) ``` ```python >>> conv = pv.ExpressionConverter( ... input_attributes=['hu'], ... output_attributes=['modulus', 'toughness'], ... expressions=['hu * 1000 + 500', '0.5 * hu + 10']) ``` -------------------------------- ### Install CadQuery with OpenVCAD Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/cadquery.md.txt Install the necessary dependencies to enable CadQuery support within the OpenVCAD environment. ```bash pip install "OpenVCAD[cad]" ``` -------------------------------- ### View 3MF package structures Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/slicer-project.md.txt Examples of typical file structures for different types of 3MF project packages. ```text generic_part.3mf [Content_Types].xml _rels/.rels 3D/3dmodel.model prusa_project.3mf 3D/3dmodel.model Metadata/Slic3r_PE.config Metadata/Slic3r_PE_model.config prusa_colormix_project.3mf 3D/3dmodel.model Metadata/Slic3r_PE_model.config Metadata/Prusa_Slicer_full_spectrum.json orca_full_spectrum_project.3mf 3D/3dmodel.model Metadata/project_settings.config Metadata/model_settings.config ``` -------------------------------- ### pyvcad_rendering.export.Export Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/python-api/pyvcad_rendering/interactive.rst.txt Starts a wx-based user interface to choose a compiler and configure its options before exporting. ```APIDOC ## pyvcad_rendering.export.Export ### Description Provides an entry point for choosing a compiler and filling its options in the UI before writing output. ### Signature `pyvcad_rendering.export.Export()` ``` -------------------------------- ### Initialize Identity node Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/composition.html Examples for creating an Identity node with or without an initial child node. ```python >>> import pyvcad as pv >>> child = pv.Sphere(10) >>> node = pv.Identity(child) ``` ```python >>> import pyvcad as pv >>> node = pv.Identity() ``` -------------------------------- ### Initialize Vec4 Vector Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/geometry.html Example showing the initialization of a 4D vector and accessing its components. ```python >>> v = Vec4(1.0, 0.0, 0.0, 1.0) # Red color with full opacity >>> print(f'({v.r}, {v.g}, {v.b}, {v.a})') (1.0, 0.0, 0.0, 1.0) ``` -------------------------------- ### Create a Multi-input STEP LookupTableConverter Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/attributes.html Example of mapping temperature and density to color and alpha values independently. ```python >>> entries = [ ... pv.LookupTableEntry([(0, 1), (0, 0.01)], [pv.Vec3(1,1,1), 0.0]), ... pv.LookupTableEntry([(1, 10), (0.01, 0.5)], [pv.Vec3(1,0,0), 0.5]), ... ] >>> conv = pv.LookupTableConverter( ... ['temperature', 'density'], ['color_rgba'], ... entries, pv.InterpolationMode.STEP) ``` -------------------------------- ### Run Attribute Modifier Example Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/attribute-resolver.md.txt Command to execute the manual attribute conversion script. ```bash python examples/3_attribute_resolver/01_attribute_modifier_flow_rate.py ``` -------------------------------- ### Regenerate Guide Assets Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/cadquery.md.txt Command to regenerate all figures associated with the CADQuery guide. ```bash python scripts/generate_cadquery_guide_assets.py ``` -------------------------------- ### Create a Single-input LINEAR LookupTableConverter Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/attributes.html Example of mapping temperature to flow rate using sorted-point interpolation. ```python >>> entries = [pv.LookupTableEntry(180, 1.0), pv.LookupTableEntry(220, 0.5)] >>> conv = pv.LookupTableConverter(['temperature'], ['flow_rate'], entries, pv.InterpolationMode.LINEAR) ``` -------------------------------- ### List installed conversion modules Source: https://matterassembly.org/OpenVCAD-Docs/v3/_modules/pyvcad_attribute_resolver/modules.html Retrieves a list of all sub-package names located under the modules directory. ```python """Domain-specific conversion modules. Each sub-package registers its own set of ConversionEntry objects. To discover the installed modules, call :func:`list_modules`. """ import importlib import pkgutil [docs] def list_modules(): """Return the names of all installed sub-packages under ``modules/``.""" return [name for _, name, is_pkg in pkgutil.iter_modules(__path__) if is_pkg] ``` -------------------------------- ### Create a Two-input LINEAR LookupTableConverter Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/attributes.html Example of mapping modulus and toughness to volume fractions using rectilinear grid interpolation. ```python >>> entry = pv.LookupTableEntry([10.0, 2.0], {1: 0.7, 2: 0.2, 3: 0.1}) >>> entry.is_valid = True >>> conv = pv.LookupTableConverter( ... ['modulus', 'toughness'], ['volume_fractions'], ... [entry], pv.InterpolationMode.LINEAR) ``` -------------------------------- ### Resolve Density to Machine Attributes Source: https://matterassembly.org/OpenVCAD-Docs/v3/guides/attribute-resolver.html Shows how to start from a design-intent attribute (density) and let the resolver derive both temperature and flow rate. ```python import pyvcad as pv import pyvcad_rendering as viz import pyvcad_attribute_resolver as resolver # Start from design intent (density) and let the resolver derive the # machine-facing attributes needed by the foaming PLA workflow. resolver.register_pla_conversions() bar_length = 180.0 bar_width = 12.0 bar_height = 12.0 density_min = 0.50 density_max = 1.00 density_slope = (density_min - density_max) / bar_length density_offset = (density_min + density_max) / 2.0 density_expr = ( f"max(min({density_slope:.8f} * x + {density_offset:.8f}, " f"{density_max:.8f}), {density_min:.8f})" ) bar = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(bar_length, bar_width, bar_height)) bar.set_attribute(pv.DefaultAttributes.DENSITY, pv.FloatAttribute(density_expr)) root = resolver.adapt(bar, ["temperature", "flow_rate"], tags=["foaming_pla"]) viz.Render(root) ``` ```bash python examples/3_attribute_resolver/03_resolver_density_to_flow_rate.py ``` -------------------------------- ### Initialize FullSpectrumSlicerProjectCompiler with explicit filaments Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/slicer-project.md.txt Configures the compiler with a specific set of physical filaments defined by slot and hex color, suitable for custom spool setups. ```python compiler = pvc.FullSpectrumSlicerProjectCompiler( root, pv.Vec3(0.25, 0.25, 0.25), out_3mf, [ {"slot": 1, "color_hex": "#00FFFF"}, {"slot": 2, "color_hex": "#FF00FF"}, {"slot": 3, "color_hex": "#FFFF00"}, {"slot": 4, "color_hex": "#000000"}, {"slot": 5, "color_hex": "#FFFFFF"}, ], max_palette_size=32, min_component_percent=15, max_recipe_components=5, ) ``` -------------------------------- ### Create a Single-input STEP LookupTableConverter Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/attributes.html Example of mapping Hounsfield Units (HU) to color values using range-based threshold matching. ```python >>> entries = [ ... pv.LookupTableEntry(-1000, -500, pv.Vec4(0,0,0,0)), ... pv.LookupTableEntry(-500, 0, pv.Vec4(1,0,0,0.5)), ... ] >>> conv = pv.LookupTableConverter(['hu'], ['color_rgba'], entries, pv.InterpolationMode.STEP) ``` -------------------------------- ### Install FEniCSx environment Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/simulation-compiler.md.txt Commands to create and activate a Conda environment containing the necessary FEniCSx and scientific computing dependencies. ```bash conda create -n fenicsx -c conda-forge fenics-dolfinx mpi4py h5py numpy conda activate fenicsx ``` -------------------------------- ### Retrieve Principal Stretches Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/geometry.html Get the ascending directional stretch estimates for a given logical coordinate. ```python >>> stretches = cell_map.principal_stretches(pv.Vec3(0.5, 0.5, 0.5)) ``` -------------------------------- ### Create project directory Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/install.md.txt Initialize a new directory for your OpenVCAD project. ```bash mkdir my_openvcad_project cd my_openvcad_project ``` -------------------------------- ### FullSpectrumSlicerProjectCompiler Constructor Options Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/slicer-project.md.txt Reference for all available parameters when initializing the FullSpectrumSlicerProjectCompiler. ```python compiler = pvc.FullSpectrumSlicerProjectCompiler( root, voxel_size, output_file_path, filaments=None, max_palette_size=32, min_component_percent=15, max_recipe_components=5, direct_physical_delta_e=1.0, region_overlap_mm=0.2, base_project_settings_path="", orca_machine_profile_path="", orca_process_profile_path="", orca_default_filament_profile_path="", orca_profile_search_paths=[], volume_fraction_materials={}, material_defs_path="", ) ``` -------------------------------- ### Initialize Mesh from File Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/leaves.html Create a Mesh node by loading a file and specifying voxelization parameters. ```python >>> import pyvcad as pv >>> node = pv.Mesh('model.stl', pv.Vec3(0.1, 0.1, 0.1), center=True) ``` -------------------------------- ### Create and activate virtual environment Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/install.md.txt Set up an isolated Python environment for the project on different operating systems. ```bash # macOS / Linux python3 -m venv openvcad-venv source openvcad-venv/bin/activate # Windows python -m venv openvcad-venv openvcad-venv\Scripts\activate ``` -------------------------------- ### Update OpenVCAD Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/install.md.txt Upgrade the existing OpenVCAD installation to the latest version. ```bash python -m pip install --upgrade OpenVCAD ``` -------------------------------- ### list_modules() Source: https://matterassembly.org/OpenVCAD-Docs/v3/_modules/pyvcad_attribute_resolver/modules.html Returns a list of names of all installed sub-packages located under the modules directory. ```APIDOC ## list_modules() ### Description Returns the names of all installed sub-packages under the modules/ directory of the pyvcad_attribute_resolver package. ### Signature `list_modules() -> List[str]` ### Returns - **List[str]**: A list of strings representing the names of the discovered sub-packages. ``` -------------------------------- ### TriangleMeshSurface.__init__ Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/geometry.html Initializes a new TriangleMeshSurface from a mesh, file path, or raw vertex/triangle data. ```APIDOC ## __init__(surface_mesh | path | vertices, triangles, u_axis_hint=None) ### Description Parameterize a disk patch from various input sources. ### Parameters - **surface_mesh** (SurfaceMesh) - Optional - Source disk patch. - **path** (str) - Optional - Mesh file path. - **vertices** (list[Vec3]) - Optional - Patch vertices. - **triangles** (list[tuple[int, int, int]]) - Optional - Consistently wound triangles. - **u_axis_hint** (Vec3) - Optional - World-space direction for the chart's u-axis. ``` -------------------------------- ### get_double_attribute_min_max Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/utilities.html Gets the min and max values of the last sampled double attribute. ```APIDOC ## get_double_attribute_min_max() ### Description Get the min and max values of the last sampled double attribute. ### Returns - **tuple** - (min, max) as floats. ``` -------------------------------- ### Initialize TriangleMeshSurface Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/geometry.html Create a TriangleMeshSurface instance from various input sources like existing meshes, files, or raw vertex data. ```python >>> surface = pv.TriangleMeshSurface(mesh) ``` ```python >>> surface = pv.TriangleMeshSurface('patch.obj') ``` ```python >>> surface = pv.TriangleMeshSurface(vertices, triangles) ``` -------------------------------- ### Vec4sVolume.__init__ Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/volumes.html Constructor for creating an empty Vec4sVDBVolume instance. ```APIDOC ## Vec4sVolume.__init__() ### Description Creates an empty Vec4sVDBVolume instance. ### Returns - **None** ``` -------------------------------- ### Initialize FullSpectrumSlicerProjectCompiler for VOLUME_FRACTIONS Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/slicer-project.md.txt Configures the compiler to map OpenVCAD material names to physical filament slots using the volume_fraction_materials dictionary. ```python compiler = pvc.FullSpectrumSlicerProjectCompiler( root, pv.Vec3(0.25, 0.25, 0.25), out_3mf, volume_fraction_materials={"red": 1, "blue": 2}, max_palette_size=10, min_component_percent=1, max_recipe_components=5, ) ``` -------------------------------- ### FullSpectrumSlicerProjectCompiler.__init__ Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad_compilers/compilers.html Constructor for the FullSpectrumSlicerProjectCompiler class, which initializes the compiler for generating Orca FullSpectrum projects. ```APIDOC ## FullSpectrumSlicerProjectCompiler.__init__ ### Description Initializes a new instance of the FullSpectrumSlicerProjectCompiler to generate .3mf project files. ### Parameters - **root** (Node) - Required - The root node of the prepared tree. - **voxel_size** (Vec3) - Required - The sampling resolution. - **output_file_path** (str) - Required - The output file path for the .3mf project. - **filaments** (list) - Optional - List of dicts with color_hex and optional slot, filament_settings_id, filament_id, filament_profile_path, nozzle_diameter_mm. - **max_palette_size** (int) - Optional - Maximum generated color palette size or volume-fraction region count. Defaults to 32. - **min_component_percent** (int) - Optional - Minimum component weight for mixed recipes. Defaults to 15. - **max_recipe_components** (int) - Optional - Maximum physical filaments per mixed recipe, capped at 3. Defaults to 3. - **direct_physical_delta_e** (float) - Optional - Legacy compatibility setting. Defaults to 1.0. - **region_overlap_mm** (float) - Optional - Small spatial overlap between generated regions. Defaults to 0.2. - **base_project_settings_path** (str) - Optional - Optional Orca project settings JSON to overlay. - **orca_machine_profile_path** (str) - Optional - Optional Orca machine profile path or name. - **orca_process_profile_path** (str) - Optional - Optional Orca process profile path or name. - **orca_default_filament_profile_path** (str) - Optional - Optional default Orca filament profile path or name. - **orca_profile_search_paths** (list) - Optional - Additional directories searched for Orca JSON profiles. - **volume_fraction_materials** (dict) - Optional - Optional material-name to physical slot mapping. - **material_defs_path** (str) - Optional - Optional MaterialDefs JSON path. - **color_mix_recipe_preset** (str) - Optional - Printable recipe set for COLOR_RGB FullSpectrum export. Defaults to 'expanded'. ``` -------------------------------- ### Implement a linear modulus gradient with FloatAttribute Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/numba-attributes.md.txt Example of applying a modulus gradient to a RectPrism using a Numba-compiled function. ```python import pyvcad as pv import pyvcad_rendering as viz from numba import cfunc, types materials = pv.default_materials length = 40.0 width = 10.0 height = 10.0 half_length = length / 2.0 modulus_min = 1.0 modulus_span = 9.0 @cfunc(types.float64(types.float64, types.float64, types.float64, types.float64)) def modulus_gradient(x, y, z, d): t = (x + half_length) / length if t < 0.0: t = 0.0 elif t > 1.0: t = 1.0 return modulus_min + modulus_span * t bar = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(length, width, height)) bar.set_attribute(pv.DefaultAttributes.MODULUS, pv.FloatAttribute(modulus_gradient)) root = bar viz.Render(root, materials) ``` -------------------------------- ### Initialize a BoxKernel Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/attribute_nodes.html Creates a uniform box averaging kernel with a specified radius. ```python >>> from libvcad import pyvcad as pv >>> kernel = pv.BoxKernel(1) ``` -------------------------------- ### Implement a color field with Vec4Attribute Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/numba-attributes.md.txt Example of defining four separate Numba functions to construct a color attribute for a geometry. ```python import pyvcad as pv import pyvcad_rendering as viz from numba import cfunc, types length = 50.0 width = 18.0 height = 8.0 half_length = length / 2.0 half_width = width / 2.0 @cfunc(types.float64(types.float64, types.float64, types.float64, types.float64)) def color_r(x, y, z, d): t = (x + half_length) / length if t < 0.0: t = 0.0 elif t > 1.0: t = 1.0 return t @cfunc(types.float64(types.float64, types.float64, types.float64, types.float64)) def color_g(x, y, z, d): t = (y + half_width) / width if t < 0.0: t = 0.0 elif t > 1.0: t = 1.0 return 0.2 + 0.6 * t @cfunc(types.float64(types.float64, types.float64, types.float64, types.float64)) def color_b(x, y, z, d): t = (x + half_length) / length if t < 0.0: t = 0.0 elif t > 1.0: t = 1.0 return 1.0 - t @cfunc(types.float64(types.float64, types.float64, types.float64, types.float64)) def color_a(x, y, z, d): return 1.0 panel = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(length, width, height)) panel.set_attribute( pv.DefaultAttributes.COLOR_RGBA, pv.Vec4Attribute(color_r, color_g, color_b, color_a), ) root = panel viz.Render(root) ``` -------------------------------- ### Initialize a CustomKernel Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/attribute_nodes.html Creates a convolution kernel using an explicit list of weights and defined radii. ```python >>> from libvcad import pyvcad as pv >>> target_size = 27 # 3x3x3 >>> kernel = pv.CustomKernel([1.0]*target_size, 1, 1, 1) ``` -------------------------------- ### Initialize Octet Lattice Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/metamaterials/attribute-modeling.md.txt Sets up a 4x4x3 octet lattice structure using a rectangular cell map. ```python cell_map = mm.rectangular_cell_map( ( pv.Vec3(-18.0, -18.0, -12.0), pv.Vec3(18.0, 18.0, 12.0), ), cells=(4, 4, 3), ) root = mm.octet( cell_map, beam_radius=0.65, node_radius=0.8, ) ``` -------------------------------- ### Initialize and execute PrusaSlicerProjectCompiler Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/slicer-project.md.txt Instantiate the compiler with specific printer and filament profiles, then trigger the compilation process. ```python compiler = pvc.PrusaSlicerProjectCompiler( root, pv.Vec3(0.25, 0.25, 0.25), out_3mf, num_regions=12, printer_profile_path=printer_profile_path, filament_profile_path=filament_profile_path, enable_color_mix=False, color_mix_filaments=None, total_physical_extruders=5, color_mix_recipe_preset="expanded", max_palette_size=32, min_component_percent=15, max_recipe_components=3, direct_physical_delta_e=1.0, region_overlap_mm=0.2, volume_fraction_materials={}, material_defs_path="", ) compiler.compile() ``` -------------------------------- ### Define Virtual Extrusion G-code Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/slicer-project.md.txt Example G-code commands used in toolchange scripts to apply temperature and flow rate settings. ```gcode M104 S{temperature} M221 S{flow_rate} ``` -------------------------------- ### FullSpectrumSlicerProjectCompiler Constructor Source: https://matterassembly.org/OpenVCAD-Docs/v3/guides/compilers/slicer-project.html Initializes a new instance of the FullSpectrumSlicerProjectCompiler with specific project settings, filament configurations, and slicer profile paths. ```APIDOC ## FullSpectrumSlicerProjectCompiler(root, voxel_size, output_file_path, ...) ### Description Constructs the compiler instance required to process FullSpectrum projects. It accepts various configuration parameters to define how filaments, colors, and slicer profiles are handled during the compilation process. ### Parameters - **root** (string) - Required - The root directory for the project. - **voxel_size** (float) - Required - The size of the voxels used in the project. - **output_file_path** (string) - Required - The destination path for the compiled output. - **filaments** (list) - Optional - Physical filament slots and colors. Each dictionary may include slot, color_hex, filament_settings_id, filament_id, filament_profile_path, and nozzle_diameter_mm. - **max_palette_size** (int) - Optional - Maximum generated COLOR_RGB palette size or VOLUME_FRACTIONS recipe-region count. - **min_component_percent** (float) - Optional - Minimum component percentage kept in generated mixed recipes. - **max_recipe_components** (int) - Optional - Maximum physical filaments allowed in one mixed recipe. - **direct_physical_delta_e** (float) - Optional - DeltaE threshold for assigning a COLOR_RGB target directly to a physical filament. - **region_overlap_mm** (float) - Optional - Small overlap between generated FullSpectrum sub-parts to avoid visible cracks. - **base_project_settings_path** (string) - Optional - Path to Orca project settings JSON to merge. - **orca_machine_profile_path** (string) - Optional - Path or resolvable name for the Orca machine profile. - **orca_process_profile_path** (string) - Optional - Path or resolvable name for the Orca process profile. - **orca_default_filament_profile_path** (string) - Optional - Path or resolvable name for the default filament profile. - **orca_profile_search_paths** (list) - Optional - Additional directories searched for Orca JSON profiles. - **volume_fraction_materials** (dict) - Optional - Material-name to physical-slot mapping for direct VOLUME_FRACTIONS export. - **material_defs_path** (string) - Optional - Path to MaterialDefs JSON. ``` -------------------------------- ### Initialize a smooth Difference node Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/composition.html Demonstrates creating a Difference node with a smoothing radius and setting its child nodes. ```python >>> from libvcad import pyvcad as pv >>> smooth_diff = pv.Difference(1.0) >>> smooth_diff.set_left(left_sphere) >>> smooth_diff.set_right(right_sphere) ``` ```python >>> from libvcad import pyvcad as pv >>> left_sphere = pv.Sphere(pv.Vec3(-2, 0, 0), 3, 1) >>> right_sphere = pv.Sphere(pv.Vec3(2, 0, 0), 3, 1) >>> smooth_diff = pv.Difference(1.0, left_sphere, right_sphere) ``` -------------------------------- ### Exporting Design Trees with pyvcad_rendering Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/getting-started.md.txt Use the rendering module to export design trees to Mermaid format or rendered image files. Rendering SVG or PNG files requires the Mermaid CLI (mmdc) to be installed. ```python import pyvcad_rendering as viz # root = your existing OpenVCAD design tree viz.Render_Tree_Diagram(root, "my_design_tree.mmd") # Mermaid source viz.Render_Tree_Diagram(root, "my_design_tree.svg") # Requires `mmdc` viz.Render_Tree_Legend("openvcad_master_legend.svg") ``` -------------------------------- ### DICOMLoader.__init__ Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/volumes.html Initializes a new DICOMLoader instance for a specified directory of DICOM files. ```APIDOC ## DICOMLoader.__init__(directory, center=False, rescale_slope=-inf, rescale_intercept=-inf, slice_thickness=-inf, x_pixel_spacing=-inf, y_pixel_spacing=-inf) ### Description Constructor for the DICOMLoader class. Creates a loader instance to process DICOM image stacks. ### Parameters - **directory** (str) - Required - The directory containing the DICOM stack. - **center** (bool) - Optional - Whether to center the volume at the origin. Default is false. - **rescale_slope** (double) - Optional - The rescale slope to apply to pixel values. - **rescale_intercept** (double) - Optional - The rescale intercept to apply to pixel values. - **slice_thickness** (double) - Optional - The slice thickness in mm. - **x_pixel_spacing** (double) - Optional - The pixel spacing in x direction in mm. - **y_pixel_spacing** (double) - Optional - The pixel spacing in y direction in mm. ``` -------------------------------- ### ColorInkjetCompiler Constructor Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/color-inkjet.md.txt Initializes a new instance of the ColorInkjetCompiler. ```APIDOC ## ColorInkjetCompiler(root, voxel_size, output_directory, file_prefix, icc_profile="default") ### Description Initializes the compiler with the specified scene root, voxel dimensions, and output configuration. ### Parameters - **root** (Node) - Required - The root node of the scene. - **voxel_size** (Vec3) - Required - Voxel spacing in mm. - **output_directory** (string) - Required - Directory path for output PNG files. - **file_prefix** (string) - Required - Filename prefix for generated slices. - **icc_profile** (string) - Optional - ICC profile stem resolved under the configured icc_profiles directory. ``` -------------------------------- ### Initialize Point2 Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/geometry.html Create a 2D point at the origin or with specific coordinates. ```python >>> p = Point2() >>> print(f'({p.x()}, {p.y()})') (0.0, 0.0) ``` ```python >>> p = Point2(1.0, 2.0) >>> print(f'({p.x()}, {p.y()})') (1.0, 2.0) ``` -------------------------------- ### Import PNG image stack as 3D volume Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/volumes.md.txt Loads an ordered directory of PNG slices to construct a true 3D color volume. ```python import os import pyvcad as pv import pyvcad_rendering as viz script_dir = os.path.dirname(os.path.abspath(__file__)) stack_dir = os.path.join(script_dir, "pyramid_stack") png_loader = pv.PNGLoader.FromStack( stack_dir, pv.Vec3(0.35, 0.35, 0.35), pv.PNGColorMode.COLOR_RGBA, center=True, ) color_volume = png_loader.as_rgba_volume() bbox_min, bbox_max = color_volume.bounding_box() carrier = pv.RectPrism.FromMinAndMax(bbox_min, bbox_max) carrier.set_attribute(pv.DefaultAttributes.COLOR_RGBA, pv.Vec4Attribute(color_volume)) root = carrier viz.Render(root) ``` -------------------------------- ### FullSpectrumSlicerProjectCompiler Constructor Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/slicer-project.md.txt Initializes the compiler to process OpenVCAD projects into FullSpectrum recipes, supporting both color-based and volume-fraction-based material mapping. ```APIDOC ## FullSpectrumSlicerProjectCompiler ### Description Initializes a new compiler instance to process an OpenVCAD project into a FullSpectrum 3MF file. It handles material mapping, palette clustering, and recipe generation. ### Constructor Signature `pvc.FullSpectrumSlicerProjectCompiler(root, voxel_size, output_file_path, filaments=None, max_palette_size=32, min_component_percent=15, max_recipe_components=5, direct_physical_delta_e=1.0, region_overlap_mm=0.2, base_project_settings_path="", orca_machine_profile_path="", orca_process_profile_path="", orca_default_filament_profile_path="", orca_profile_search_paths=[], volume_fraction_materials={}, material_defs_path="")` ### Parameters - **root** (object) - The root OpenVCAD project object. - **voxel_size** (Vec3) - The dimensions of the voxels for the project. - **output_file_path** (string) - The destination path for the generated 3MF file. - **filaments** (dict, optional) - Physical filament slots and colors. - **max_palette_size** (int, optional) - Maximum generated COLOR_RGB palette size or VOLUME_FRACTIONS recipe-region count. - **min_component_percent** (int, optional) - Minimum component percentage kept in generated mixed recipes. - **max_recipe_components** (int, optional) - Maximum physical filaments allowed in one mixed recipe. - **direct_physical_delta_e** (float, optional) - DeltaE threshold for assigning a COLOR_RGB target directly to a physical filament. - **region_overlap_mm** (float, optional) - Small overlap between generated FullSpectrum sub-parts. - **base_project_settings_path** (string, optional) - Optional Orca project settings JSON path. - **orca_machine_profile_path** (string, optional) - Optional Orca machine profile path. - **orca_process_profile_path** (string, optional) - Optional Orca process profile path. - **orca_default_filament_profile_path** (string, optional) - Optional default filament profile path. - **orca_profile_search_paths** (list, optional) - Additional directories searched for Orca JSON profiles. - **volume_fraction_materials** (dict, optional) - Material-name to physical-slot mapping for direct VOLUME_FRACTIONS export. - **material_defs_path** (string, optional) - Optional MaterialDefs JSON path. ``` -------------------------------- ### pyvcad_rendering.export.Export(*args, **kwargs) Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad_rendering/interactive.html The entry point for choosing a compiler and filling its options in the UI before writing output. ```APIDOC ## pyvcad_rendering.export.Export(*args, **kwargs) ### Description The entry point for choosing a compiler and filling its options in the UI before writing output. Concrete compiler classes are defined in pyvcad_compilers. ### Parameters - **args** (list) - Optional - Positional arguments for the export process. - **kwargs** (dict) - Optional - Keyword arguments for the export process. ``` -------------------------------- ### Create a Difference Node Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/composition.html Demonstrates how to instantiate a Difference node using two sphere nodes. ```python >>> from libvcad import pyvcad as pv >>> radius = 5 >>> left_sphere = pv.Sphere(pv.Vec3(-radius/2, 0, 0), radius, 1) >>> right_sphere = pv.Sphere(pv.Vec3(radius/2, 0, 0), radius, 1) >>> difference = pv.Difference(left_sphere, right_sphere) ``` -------------------------------- ### Create a Parametric Equipment Bracket Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/cadquery.md.txt Constructs a base with holes and an upright, then applies a modulus attribute to the model for stiffness simulation. ```python import cadquery as cq import pyvcad as pv import pyvcad_rendering as viz base_length = 64.0 base_width = 36.0 base_thickness = 5.0 upright_height = 48.0 upright_thickness = 6.0 mounting_hole_diameter = 6.0 mounting_hole_spacing = 42.0 modulus_min = 1200.0 modulus_max = 4200.0 base = ( cq.Workplane("XY") .box(base_length, base_width, base_thickness) .faces(">Z") .workplane() .pushPoints([(-mounting_hole_spacing / 2.0, 0.0), (mounting_hole_spacing / 2.0, 0.0)]) .hole(mounting_hole_diameter) ) upright = ( cq.Workplane("XY") .box(upright_thickness, base_width, upright_height) .translate((base_length / 2.0 - upright_thickness / 2.0, 0.0, upright_height / 2.0)) ) cadquery_part = base.union(upright) root = pv.CADModel.from_cadquery(cadquery_part).to_node(use_fast_mode=True) modulus_expr = ( f"{modulus_min} + ({modulus_max} - {modulus_min}) " f"* clamp(z / {upright_height}, 0, 1)" ) root.set_attribute(pv.DefaultAttributes.MODULUS, pv.FloatAttribute(modulus_expr)) viz.Render(root) ``` -------------------------------- ### Load a CAD model from BREP Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/geometry.html Load an ASCII BREP model from a file path. ```python >>> model = pv.CADModel.from_brep('part.brep') ``` -------------------------------- ### Compile OpenVCAD design to PNG slices Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/material-inkjet.md.txt Configures a rectangular prism with a material gradient and compiles it into a stack of PNG images using the MaterialInkjetCompiler. ```python import os import shutil import pyvcad as pv import pyvcad_compilers as pvc import pyvcad_rendering as viz materials = pv.default_materials cube = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(20, 10, 10)) fraction_gradient = pv.VolumeFractionsAttribute( [ ("x/20 + 0.5", materials.id("blue")), ("-x/20 + 0.5", materials.id("red")) ] ) cube.set_attribute(pv.DefaultAttributes.VOLUME_FRACTIONS, fraction_gradient) root = cube voxel_size = pv.Vec3(0.0423, 0.0846, 0.027) output_dir = os.path.join(os.path.dirname(__file__), "output") prefix = "slice_" if os.path.isdir(output_dir): shutil.rmtree(output_dir) os.makedirs(output_dir, exist_ok=True) compiler = pvc.MaterialInkjetCompiler( root, voxel_size, output_dir, prefix, materials, 0.0, pvc.MaterialInkjetExportMode.STOCHASTIC, ) def on_progress(p): print("compile progress: {:.1f}%".format(100.0 * p)) compiler.set_progress_callback(on_progress) compiler.compile() print("resolution (x, y, z png count):", compiler.resolution()) print("material voxel counts:", compiler.material_voxel_counts()) viz.Render(root, materials) ``` -------------------------------- ### Initialize VatCompiler in Printer-Volume Mode Source: https://matterassembly.org/OpenVCAD-Docs/v3/guides/compilers/vat-photo.html Use this constructor when the output requires a fixed XY canvas aligned to a specific printer build area. ```python VatCompiler(root, voxel_size, printer_volume, output_directory, file_prefix) ``` -------------------------------- ### render(vcad_object, materials=None) Source: https://matterassembly.org/OpenVCAD-Docs/v3/_modules/pyvcad_rendering/render.html Opens an interactive 3D viewer for the provided vcad_object using a wxPython main loop. ```APIDOC ## render(vcad_object, materials=None) ### Description Opens the interactive 3D viewer for the specified vcad_object. This function initiates a wxPython main loop. ### Parameters - **vcad_object** (object) - Required - The 3D object to be rendered. - **materials** (dict) - Optional - Material definitions for the object. ``` -------------------------------- ### CADModel::from_brep Source: https://matterassembly.org/OpenVCAD-Docs/v3/cpp-api/libvcad-geometry-3d.html Creates a CADModel instance from a B-Rep file path. ```APIDOC ## static std::shared_ptr from_brep(const std::string &path) ### Description Loads a CAD model from a B-Rep file located at the specified path. ### Parameters - **path** (std::string) - Required - The file system path to the B-Rep file. ``` -------------------------------- ### Execute simulation workflow Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/simulation-compiler.md.txt Commands to activate the required environment and run the simulation script. ```bash conda activate fenicsx python examples/compilers/simulation/03_fenicsx_load_exported_design.py ``` -------------------------------- ### Create a parametric mounting plate for OpenVCAD Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/cadquery.md.txt Constructs a base plate with a boss and hole using CadQuery, then maps a modulus gradient across the geometry for OpenVCAD rendering. ```python import cadquery as cq import pyvcad as pv import pyvcad_rendering as viz plate_length = 48.0 plate_width = 30.0 plate_thickness = 4.0 boss_length = 28.0 boss_width = 14.0 boss_height = 8.0 hole_diameter = 6.0 modulus_min = 800.0 modulus_max = 2800.0 cadquery_part = ( cq.Workplane("XY") .box(plate_length, plate_width, plate_thickness) .faces(">Z") .workplane() .rect(boss_length, boss_width) .extrude(boss_height) .faces(">Z") .workplane() .hole(hole_diameter) ) root = pv.CADModel.from_cadquery(cadquery_part).to_node(use_fast_mode=True) modulus_expr = ( f"{modulus_min} + ({modulus_max} - {modulus_min}) " f"* ((x + {plate_length / 2.0}) / {plate_length})" ) root.set_attribute(pv.DefaultAttributes.MODULUS, pv.FloatAttribute(modulus_expr)) viz.Render(root) ``` -------------------------------- ### Build a finite rectangular map Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/metamaterials/catalog.md.txt Initializes a CellMap for metamaterial generation using defined world bounds and cell counts. ```python import pyvcad as pv import pyvcad_metamaterials as mm cell_map = mm.rectangular_cell_map( (pv.Vec3(-15.0, -15.0, -15.0), pv.Vec3(15.0, 15.0, 15.0)), cells=(3, 3, 3), ) ``` -------------------------------- ### Load a CAD model from STEP Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/geometry.html Load a STEP or STP model from a file path. ```python >>> model = pv.CADModel.from_step('part.step') ``` -------------------------------- ### Initialize a default PolygonExtrude Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/leaves.html Creates a unit square in the XY plane extruded 1 unit in +Z using the default constructor. ```python >>> from libvcad import pyvcad as pv >>> poly = pv.PolygonExtrude() ``` -------------------------------- ### VatCompiler Constructors Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/vat-photo.md.txt Initializes a new VatCompiler instance. Two constructors are available: one for bounding-box compilation and one for fixed printer-volume compilation. ```APIDOC ## VatCompiler(root, voxel_size, output_directory, file_prefix) ### Description Initializes a compiler that compiles only the model bounding box. ## VatCompiler(root, voxel_size, printer_volume, output_directory, file_prefix) ### Description Initializes a compiler that compiles onto a fixed printer-volume XY canvas with centered XY placement. ``` -------------------------------- ### export_iso_surface_vtk(vcad_object, file_path, quality='high', use_blending=True, progress_callback=None) Source: https://matterassembly.org/OpenVCAD-Docs/v3/_modules/pyvcad_rendering/vtk_export.html Exports the colored iso-surface of a given OpenVCAD object to a .vtp file. It computes the colors for all defined attributes and adds them as arrays in the PointData. ```APIDOC ### Function: export_iso_surface_vtk #### Description Exports the colored iso-surface of a given OpenVCAD object to a .vtp file. It computes the colors for all defined attributes and adds them as arrays in the PointData. #### Parameters - **vcad_object** (object) - Required - The OpenVCAD node to export. - **file_path** (str) - Required - The destination file path (.vtp is recommended). - **quality** (str) - Optional - The sampling quality profile ("low", "medium", "high", "ultra"). Defaults to "high". - **use_blending** (bool) - Optional - Whether to use alpha blending. Defaults to True. - **progress_callback** (callable) - Optional - Callback for progress updates taking a float (0-100). ``` -------------------------------- ### Initialize MappedGraphLattice Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/leaves.html Constructs a mapped graph lattice node using a cell map, unit cell, and radius. ```python >>> node = pv.MappedGraphLattice(cell_map, cell, radius) ``` -------------------------------- ### Initialize Vec4 Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/geometry.html Create a 4D vector representing RGBA components. ```python >>> v = Vec4() >>> print(f'({v.r}, {v.g}, {v.b}, {v.a})') (0.0, 0.0, 0.0, 0.0) ``` -------------------------------- ### CADModel.from_brep Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/geometry.html Loads an ASCII BREP model from a file path. ```APIDOC ## static CADModel.from_brep(path: str) ### Description Loads an ASCII BREP model from the specified file path. ### Parameters - **path** (str) - Required - BREP file path. ### Example ```python model = pv.CADModel.from_brep('part.brep') ``` ``` -------------------------------- ### Compile geometry to PNG slices Source: https://matterassembly.org/OpenVCAD-Docs/v3/_sources/guides/compilers/color-inkjet.md.txt Configures a RectPrism with a color gradient and compiles it into a series of PNG images using the ColorInkjetCompiler. ```python import os import shutil import pyvcad as pv import pyvcad_compilers as pvc import pyvcad_rendering as viz materials = pv.default_materials cube = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(20, 10, 10)) r_expr = "x/20 + 0.5" g_expr = "-x/20 + 0.5" b_expr = "x/20 + 0.5" a_expr = "1.0" color_gradient = pv.Vec4Attribute(r_expr, g_expr, b_expr, a_expr) cube.set_attribute(pv.DefaultAttributes.COLOR_RGBA, color_gradient) root = cube voxel_size = pv.Vec3(0.15, 0.15, 0.15) output_dir = os.path.join(os.path.dirname(__file__), "output") prefix = "slice_" if os.path.isdir(output_dir): shutil.rmtree(output_dir) os.makedirs(output_dir, exist_ok=True) compiler = pvc.ColorInkjetCompiler(root, voxel_size, output_dir, prefix, "default") def on_progress(p): print("compile progress: {:.1f}%".format(100.0 * p)) compiler.set_progress_callback(on_progress) compiler.compile() print("resolution (x, y, z png count):", compiler.resolution()) viz.Render(root, materials) ``` -------------------------------- ### pyvcad.SurfaceReliefVolume Source: https://matterassembly.org/OpenVCAD-Docs/v3/python-api/pyvcad/leaves.html Constructor for creating a SurfaceReliefVolume. ```APIDOC ## __init__(self, surface, height_field, embed_mm, edge_falloff_mm=0.0) -> None ### Description Initializes a new SurfaceReliefVolume operand over a parametric surface. ### Parameters - **surface** (ParametricSurface) - Required - The parametric surface to apply the relief to. - **height_field** (HeightField) - Required - The height field defining the relief. - **embed_mm** (SupportsFloat) - Required - The inward extension distance. - **edge_falloff_mm** (SupportsFloat) - Optional - The edge falloff distance. ``` -------------------------------- ### Initialize VatCompiler in Bounding-Box Mode Source: https://matterassembly.org/OpenVCAD-Docs/v3/guides/compilers/vat-photo.html Use this constructor to generate output stacks that fit the model's bounding box rather than a fixed machine canvas. ```python VatCompiler(root, voxel_size, output_directory, file_prefix) ``` -------------------------------- ### compile() Source: https://matterassembly.org/OpenVCAD-Docs/v3/guides/compilers/slicer-project.html Executes the compilation process based on the parameters provided during initialization. ```APIDOC ## Method: compile() ### Description Triggers the compilation of the design tree into the specified 3MF output file using the configured settings. ```