MCPcopy Index your code
hub / github.com/CadQuery/cadquery / export

Method export

cadquery/assembly.py:564–628  ·  view source on GitHub ↗

Save assembly to a file. :param path: Path and filename for writing. :param exportType: export format (default: None, results in format being inferred form the path) :param mode: STEP only - See :meth:`~cadquery.occ_impl.exporters.assembly.exportAssembly`. :

(
        self,
        path: str,
        exportType: Optional[ExportLiterals] = None,
        mode: STEPExportModeLiterals = "default",
        tolerance: float = 0.1,
        angularTolerance: float = 0.1,
        unit: UnitLiterals = "MM",
        outputUnit: Optional[UnitLiterals] = None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

562 )
563
564 def export(
565 self,
566 path: str,
567 exportType: Optional[ExportLiterals] = None,
568 mode: STEPExportModeLiterals = "default",
569 tolerance: float = 0.1,
570 angularTolerance: float = 0.1,
571 unit: UnitLiterals = "MM",
572 outputUnit: Optional[UnitLiterals] = None,
573 **kwargs,
574 ) -> Self:
575 """
576 Save assembly to a file.
577
578 :param path: Path and filename for writing.
579 :param exportType: export format (default: None, results in format being inferred form the path)
580 :param mode: STEP only - See :meth:`~cadquery.occ_impl.exporters.assembly.exportAssembly`.
581 :param tolerance: the deflection tolerance, in model units. Only used for glTF, VRML. Default 0.1.
582 :param angularTolerance: the angular tolerance, in radians. Only used for glTF, VRML. Default 0.1.
583 :param unit: The internal unit of the model's geometry values. Only used for STEP. Default "MM".
584 :type unit: UnitLiterals
585 :param outputUnit: The unit to use in the STEP file header. If None, defaults to the value of ``unit``.
586 Use this when you want the output file to declare a different unit than the model's internal unit,
587 for example to export a MM model as a STEP file declaring meters.
588 :type outputUnit: UnitLiterals or None
589 :param \\**kwargs: Additional keyword arguments. Only used for STEP, glTF and STL.
590 See :meth:`~cadquery.occ_impl.exporters.assembly.exportAssembly`.
591 :param ascii: STL only - Sets whether or not STL export should be text or binary
592 :type ascii: bool
593 """
594
595 # Make sure the export mode setting is correct
596 if mode not in get_args(STEPExportModeLiterals):
597 raise ValueError(f"Unknown assembly export mode {mode} for STEP")
598
599 if exportType is None:
600 t = path.split(".")[-1].upper()
601 if t in ("STEP", "XML", "XBF", "VRML", "VTKJS", "GLTF", "GLB", "STL"):
602 exportType = cast(ExportLiterals, t)
603 else:
604 raise ValueError("Unknown extension, specify export type explicitly")
605
606 if exportType == "STEP":
607 exportAssembly(self, path, mode, unit, outputUnit, **kwargs)
608 elif exportType == "XML":
609 exportCAF(self, path, False)
610 elif exportType == "XBF":
611 exportCAF(self, path, True)
612 elif exportType == "VRML":
613 exportVRML(self, path, tolerance, angularTolerance)
614 elif exportType == "GLTF" or exportType == "GLB":
615 exportGLTF(self, path, None, tolerance, angularTolerance)
616 elif exportType == "VTKJS":
617 exportVTKJS(self, path)
618 elif exportType == "STL":
619 # Handle the ascii setting for STL export
620 export_ascii = False
621 if "ascii" in kwargs:

Callers 5

saveMethod · 0.95
make_modelFunction · 0.95

Calls 8

toCompoundMethod · 0.95
exportAssemblyFunction · 0.85
exportCAFFunction · 0.85
exportVRMLFunction · 0.85
exportGLTFFunction · 0.85
exportVTKJSFunction · 0.85
exportStlMethod · 0.80
splitMethod · 0.45

Tested by 4

make_modelFunction · 0.76