|
21 | 21 | from OCP.RWGltf import RWGltf_CafWriter |
22 | 22 | from OCP.TColStd import TColStd_IndexedDataMapOfStringString |
23 | 23 | from OCP.Message import Message_ProgressRange |
| 24 | +from OCP.Interface import Interface_Static |
24 | 25 |
|
25 | 26 | from ..assembly import AssemblyProtocol, toCAF, toVTK |
26 | 27 |
|
27 | 28 |
|
28 | | -def exportAssembly(assy: AssemblyProtocol, path: str) -> bool: |
| 29 | +def exportAssembly(assy: AssemblyProtocol, path: str, **kwargs) -> bool: |
29 | 30 | """ |
30 | | - Export an assembly to a step a file. |
| 31 | + Export an assembly to a STEP file. |
| 32 | +
|
| 33 | + kwargs is used to provide optional keyword arguments to configure the exporter. |
| 34 | +
|
| 35 | + :param assy: assembly |
| 36 | + :param path: Path and filename for writing |
| 37 | + :param write_pcurves: Enable or disable writing parametric curves to the STEP file. Default True. |
| 38 | +
|
| 39 | + If False, writes STEP file without pcurves. This decreases the size of the resulting STEP file. |
| 40 | + :type write_pcurves: boolean |
| 41 | + :param precision_mode: Controls the uncertainty value for STEP entities. Specify -1, 0, or 1. Default 0. |
| 42 | + See OCCT documentation. |
| 43 | + :type precision_mode: int |
31 | 44 | """ |
32 | 45 |
|
| 46 | + # Handle the extra settings for the STEP export |
| 47 | + pcurves = 1 |
| 48 | + if "write_pcurves" in kwargs and not kwargs["write_pcurves"]: |
| 49 | + pcurves = 0 |
| 50 | + precision_mode = kwargs["precision_mode"] if "precision_mode" in kwargs else 0 |
| 51 | + |
33 | 52 | _, doc = toCAF(assy, True) |
34 | 53 |
|
35 | 54 | session = XSControl_WorkSession() |
36 | 55 | writer = STEPCAFControl_Writer(session, False) |
37 | 56 | writer.SetColorMode(True) |
38 | 57 | writer.SetLayerMode(True) |
39 | 58 | writer.SetNameMode(True) |
| 59 | + Interface_Static.SetIVal_s("write.surfacecurve.mode", pcurves) |
| 60 | + Interface_Static.SetIVal_s("write.precision.mode", precision_mode) |
40 | 61 | writer.Transfer(doc, STEPControl_StepModelType.STEPControl_AsIs) |
41 | 62 |
|
42 | 63 | status = writer.Write(path) |
|
0 commit comments