Refer to the B-Rep Geometry Creation Example.
edgeutil.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33import sys
34from pathlib import Path
35import os
36
37
38import cadexchanger.CadExCore as cadex
39import math
40
42
43def MakeEdgeFromLine() -> cadex.ModelData_Edge:
46
47def MakeEdgeFromCircle() -> cadex.ModelData_Edge:
50
51def MakeEdgeFromEllipse() -> cadex.ModelData_Edge:
54
55def MakeEdgeFromParabola() -> cadex.ModelData_Edge:
58
59def MakeEdgeFromHyperbola() -> cadex.ModelData_Edge:
62
63def MakeEdgeFromOffSetCurve() -> cadex.ModelData_Edge:
67
68def MakeEdgeFromOffsetCurve() -> cadex.ModelData_Edge:
72
73def MakeEdgeFromBezier() -> cadex.ModelData_Edge:
74 aPoles = [
79 ]
80
83
84def MakeEdgeFromBSpline() -> cadex.ModelData_Edge:
85 aPoles = [
91 ]
92
93 aKnots = [ 0.0, 0.25, 0.75, 1.0 ]
94
95 aMultiplicities = [ 3, 1, 1, 3 ]
96
97 aDegree = 2
Defines a right-hand axis placement in 3D.
Definition: ModelData_Axis2Placement.hxx:38
Defines 3D B-Spline curve.
Definition: ModelData_BSplineCurve.hxx:34
Defines 3D Bezier curve.
Definition: ModelData_BezierCurve.hxx:36
Defines 3D circle.
Definition: ModelData_Circle.hxx:33
static const ModelData_Direction & ZDir()
Definition: ModelData_Direction.cxx:108
static const ModelData_Direction & XDir()
Definition: ModelData_Direction.cxx:96
Defines an edge.
Definition: ModelData_Edge.hxx:36
Defines 3D ellipse.
Definition: ModelData_Ellipse.hxx:32
Defines 3D hyperbola.
Definition: ModelData_Hyperbola.hxx:32
Defines 3D line.
Definition: ModelData_Line.hxx:36
Defines 3D offset curve.
Definition: ModelData_OffsetCurve.hxx:33
Defines 3D parabola.
Definition: ModelData_Parabola.hxx:32
Defines a 3D point.
Definition: ModelData_Point.hxx:295
faceutil.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33import sys
34from pathlib import Path
35import os
36
37
38import cadexchanger.CadExCore as cadex
39import math
40
42
43def MakePlanarFace() -> cadex.ModelData_Face:
46
47def MakeSphericalFace() -> cadex.ModelData_Face:
50
51def MakeCylindricalFace() -> cadex.ModelData_Face:
54
55def MakeConicalFace() -> cadex.ModelData_Face:
58
59def MakeToroidalFace() -> cadex.ModelData_Face:
62
63def MakeFaceFromSurfaceOfLinearExtrusion() -> cadex.ModelData_Face:
64 aPoles = [
70 ]
71
73
76
77def MakeFaceFromSurfaceOfRevolution() -> cadex.ModelData_Face:
78 aPoles = [
84 ]
85
87
92
93def MakeFaceFromOffsetSurface() -> cadex.ModelData_Face:
94 aPoles = [
99 ]
100
104
105def MakeFaceFromBezier() -> cadex.ModelData_Face:
106 aPoles = [
111 ]
112
115
116def MakeFaceFromBSpline() -> cadex.ModelData_Face:
117 aPoles = [
123
129
135
141
147 ]
148
149 aUPoles = 5
150 aVPoles = 5
151
152 aUKnots = [ 0.0, 0.25, 0.75, 1.0]
153 aVKnots = [ 0.0, 0.25, 0.75, 1.0 ]
154
155 aVMultiplicities = [ 3, 1, 1, 3 ]
156 aUMultiplicities = [ 3, 1, 1, 3 ]
157
158 aUDegree = 2
159 aVDegree = 2
160
162 aUMultiplicities, aVMultiplicities,
163 aUDegree, aVDegree)
165
166def MakeFaceWithInnerWire() -> cadex.ModelData_Face:
170
173
176
180
181 aFace.Append(anOuterWire)
182 aFace.Append(anInnerWire)
183
184 return aFace
Defines a right-handed or left-handed axis placement in 3D.
Definition: ModelData_Axis3Placement.hxx:38
Defines a B-Spline surface.
Definition: ModelData_BSplineSurface.hxx:34
Defines a Bezier surface.
Definition: ModelData_BezierSurface.hxx:34
Defines a conical surface.
Definition: ModelData_ConicalSurface.hxx:32
Defines a cylindrical surface.
Definition: ModelData_CylindricalSurface.hxx:32
static const ModelData_Edge & Cast(const ModelData_Shape &theShape)
Casts a base class object to ModelData_Edge.
Definition: ModelData_Edge.cxx:688
Defines a topological face.
Definition: ModelData_Face.hxx:32
Defines an offset surface.
Definition: ModelData_OffsetSurface.hxx:32
Defines a plane.
Definition: ModelData_Plane.hxx:32
Defines a spherical surface.
Definition: ModelData_SphericalSurface.hxx:32
Defines a surface of linear extrusion.
Definition: ModelData_SurfaceOfLinearExtrusion.hxx:34
Defines a surface of revolution.
Definition: ModelData_SurfaceOfRevolution.hxx:35
Defines a toroidal surface.
Definition: ModelData_ToroidalSurface.hxx:32
Defines a connected set of edges.
Definition: ModelData_Wire.hxx:31
bodyutil.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33import sys
34from pathlib import Path
35import os
36
37
38import cadexchanger.CadExCore as cadex
39
40sys.path.append(os.path.abspath(os.path.dirname(Path(__file__).resolve()) + r"/../../"))
41
42
43def MakeSolidBody() -> cadex.ModelData_Body:
46 return aBody;
47
48def MakeSheetBody() -> cadex.ModelData_Body:
52
54 aShell.Append(aFace2);
55
57 return aBody;
58
59def MakeWireframeBody() -> cadex.ModelData_Body:
66
68 aWire.Append(anEdge2);
69
71 return aBody;
72
73def MakeAcornBody() -> cadex.ModelData_Body:
76 return aBody;
static ModelData_Solid CreateBox(double theDx, double theDy, double theDz)
Creates a box.
Definition: ModelAlgo_TopoPrimitives.cxx:86
static ModelData_Body Create(const ModelData_Shape &theShape)
Creates a body from an arbitrary shape.
Definition: ModelData_Body.cxx:223
Defines a connected set of faces.
Definition: ModelData_Shell.hxx:31
Defines topological vertex.
Definition: ModelData_Vertex.hxx:31
brep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33import sys
34from pathlib import Path
35import os
36
37import cadexchanger.CadExCore as cadex
38import bodyutil
39import edgeutil
40import faceutil
41
42sys.path.append(os.path.abspath(os.path.dirname(Path(__file__).resolve()) + r"/../../"))
43import cadex_license as license
44
45
46def SaveModel(theShape: cadex.ModelData_Shape, theName: str) -> bool:
50 aModel.AddRoot(aPart)
51
52 aPath = "out/" + str(theName) + ".cdx"
54
55def main():
56 aKey = license.Value()
57
58 if not cadex.LicenseManager.Activate(aKey):
59 print("Failed to activate CAD Exchanger license.")
60 return 1
61
62 aLine = edgeutil.MakeEdgeFromLine()
64 aCircle = edgeutil.MakeEdgeFromCircle()
66 anEllipse = edgeutil.MakeEdgeFromEllipse()
68 aParabola = edgeutil.MakeEdgeFromParabola()
70 aHyperbola = edgeutil.MakeEdgeFromHyperbola()
72 anEdgeFromOffsetCurve = edgeutil.MakeEdgeFromOffSetCurve()
74 aBezierEdge = edgeutil.MakeEdgeFromBezier()
76 aBSplineEdge = edgeutil.MakeEdgeFromBSpline()
78
79 aPlane = faceutil.MakePlanarFace()
81 aSphere = faceutil.MakeSphericalFace()
83 aCylinder = faceutil.MakeCylindricalFace()
85 aCone = faceutil.MakeConicalFace()
87 aTorus = faceutil.MakeToroidalFace()
89 aFaceFromLESurface = faceutil.MakeFaceFromSurfaceOfLinearExtrusion()
91 aFaceFromRevSurface = faceutil.MakeFaceFromSurfaceOfRevolution()
93 aFaceFromOffsetSurface = faceutil.MakeFaceFromOffsetSurface()
95 aBezierFace = faceutil.MakeFaceFromBezier()
97 aBSplineFace = faceutil.MakeFaceFromBSpline()
99 aFace = faceutil.MakeFaceWithInnerWire()
101
102 aSolid = bodyutil.MakeSolidBody()
104 aSheet = bodyutil.MakeSheetBody()
106 aWireframe = bodyutil.MakeWireframeBody()
108 anAcorn = bodyutil.MakeAcornBody()
110
111 print("Completed")
112 return 0
113
114if __name__ == "__main__":
115 sys.exit(main())
116
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
Defines precise Boundary Representation of part.
Definition: ModelData_BRepRepresentation.hxx:39
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
Writes any format that CAD Exchanger can export.
Definition: ModelData_ModelWriter.hxx:33
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35