MCPcopy
hub / github.com/CadQuery/cadquery / exportAssembly

Function exportAssembly

cadquery/occ_impl/exporters/assembly.py:62–166  ·  view source on GitHub ↗

Export an assembly to a STEP file. kwargs is used to provide optional keyword arguments to configure the exporter. :param assy: assembly :param path: Path and filename for writing :param mode: STEP export mode. The options are "default", and "fused" (a single fused compound).

(
    assy: AssemblyProtocol,
    path: str,
    mode: STEPExportModeLiterals = "default",
    unit: UnitLiterals = "MM",
    outputUnit: Optional[UnitLiterals] = None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

60
61
62def exportAssembly(
63 assy: AssemblyProtocol,
64 path: str,
65 mode: STEPExportModeLiterals = "default",
66 unit: UnitLiterals = "MM",
67 outputUnit: Optional[UnitLiterals] = None,
68 **kwargs,
69) -> bool:
70 """
71 Export an assembly to a STEP file.
72
73 kwargs is used to provide optional keyword arguments to configure the exporter.
74
75 :param assy: assembly
76 :param path: Path and filename for writing
77 :param mode: STEP export mode. The options are "default", and "fused" (a single fused compound).
78 It is possible that fused mode may exhibit low performance.
79 :param unit: The internal unit of the model's geometry values. Default "MM".
80 :type unit: UnitLiterals
81 :param outputUnit: The unit to use in the STEP file header. If None, defaults to the value of ``unit``.
82 Use this when you want the output file to declare a different unit than the model's internal unit,
83 for example to export a MM model as a STEP file declaring meters.
84 :type outputUnit: UnitLiterals or None
85 :param fuzzy_tol: OCCT fuse operation tolerance setting used only for fused assembly export.
86 :type fuzzy_tol: float
87 :param glue: Enable gluing mode for improved performance during fused assembly export.
88 This option should only be used for non-intersecting shapes or those that are only touching or partially overlapping.
89 Note that when glue is enabled, the resulting fused shape may be invalid if shapes are intersecting in an incompatible way.
90 Defaults to False.
91 :type glue: bool
92 :param write_pcurves: Enable or disable writing parametric curves to the STEP file. Default True.
93 If False, writes STEP file without pcurves. This decreases the size of the resulting STEP file.
94 :type write_pcurves: bool
95 :param precision_mode: Controls the uncertainty value for STEP entities. Specify -1, 0, or 1. Default 0.
96 See OCCT documentation.
97 :type precision_mode: int
98 :param name_geometries: Propagate subshape names to geometric STEP entities.
99 :type name_geometries: bool
100 """
101
102 # Handle the extra settings for the STEP export
103 pcurves = 1
104 if "write_pcurves" in kwargs and not kwargs["write_pcurves"]:
105 pcurves = 0
106 precision_mode = kwargs["precision_mode"] if "precision_mode" in kwargs else 0
107 fuzzy_tol = kwargs["fuzzy_tol"] if "fuzzy_tol" in kwargs else None
108 glue = kwargs["glue"] if "glue" in kwargs else False
109 name_geometries = kwargs.get("name_geometries", False)
110
111 # Handle the doc differently based on which mode we are using
112 if mode == "fused":
113 _, doc = toFusedCAF(assy, glue, fuzzy_tol)
114 else: # Includes "default"
115 _, doc = toCAF(assy, True,)
116
117 session = XSControl_WorkSession()
118 writer = STEPCAFControl_Writer(session, False)
119 writer.SetColorMode(True)

Calls 3

toFusedCAFFunction · 0.85
toCAFFunction · 0.85
WriteMethod · 0.80