GeezerVison is showing github.com — Fixed classic bottle · hovedguy/pythonocc-demos@1bcec6b
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: examples/core_classic_occ_bottle.py +7-7Lines changed: 7 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,7 +44,7 @@ def face_is_plane(face): | 44 | 44 | hs = BRep_Tool_Surface(face) | 45 | 45 | downcast_result = Geom_Plane.DownCast(hs) | 46 | 46 | # The handle is null if downcast failed or is not possible, that is to say the face is not a plane | 47 | | - if downcast_result.IsNull(): | | 47 | + if downcast_result is None: | 48 | 48 | return False | 49 | 49 | else: | 50 | 50 | return True | @@ -176,19 +176,19 @@ def geom_plane_from_face(aFace): | 176 | 176 | anEllipse1 = Geom2d_Ellipse(anAx2d, aMajor, aMinor) | 177 | 177 | anEllipse2 = Geom2d_Ellipse(anAx2d, aMajor, aMinor / 4.0) | 178 | 178 |
| 179 | | -anArc1 = Geom2d_TrimmedCurve(Geom2d_Ellipse(anEllipse1), 0, math.pi) | 180 | | -anArc2 = Geom2d_TrimmedCurve(Geom2d_Ellipse(anEllipse2), 0, math.pi) | | 179 | +anArc1 = Geom2d_TrimmedCurve(anEllipse1, 0, math.pi) | | 180 | +anArc2 = Geom2d_TrimmedCurve(anEllipse2, 0, math.pi) | 181 | 181 |
| 182 | 182 | anEllipsePnt1 = anEllipse1.Value(0) | 183 | 183 | anEllipsePnt2 = anEllipse1.Value(math.pi) | 184 | 184 |
| 185 | 185 | aSegment = GCE2d_MakeSegment(anEllipsePnt1, anEllipsePnt2) | 186 | 186 |
| 187 | 187 | # Build edges and wires for threading | 188 | | -anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(Geom2d_Curve(anArc1), Geom_Surface(aCyl1)) | 189 | | -anEdge2OnSurf1 = BRepBuilderAPI_MakeEdge(aSegment.Value(), Geom_Surface(aCyl1)) | 190 | | -anEdge1OnSurf2 = BRepBuilderAPI_MakeEdge(Geom2d_Curve(anArc2), Geom_Surface(aCyl2)) | 191 | | -anEdge2OnSurf2 = BRepBuilderAPI_MakeEdge(aSegment.Value(), Geom_Surface(aCyl2)) | | 188 | +anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(anArc1, aCyl1) | | 189 | +anEdge2OnSurf1 = BRepBuilderAPI_MakeEdge(aSegment.Value(), aCyl1) | | 190 | +anEdge1OnSurf2 = BRepBuilderAPI_MakeEdge(anArc2, aCyl2) | | 191 | +anEdge2OnSurf2 = BRepBuilderAPI_MakeEdge(aSegment.Value(), aCyl2) | 192 | 192 |
| 193 | 193 | threadingWire1 = BRepBuilderAPI_MakeWire(anEdge1OnSurf1.Edge(), anEdge2OnSurf1.Edge()) | 194 | 194 | threadingWire2 = BRepBuilderAPI_MakeWire(anEdge1OnSurf2.Edge(), anEdge2OnSurf2.Edge()) | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_geometry_surface_from_curves.py +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 25 | 25 | GeomFill_CoonsStyle, | 26 | 26 | GeomFill_CurvedStyle) | 27 | 27 | from OCC.Core.GeomAPI import GeomAPI_PointsToBSpline | 28 | | -from OCC.Core.Geom import Geom_BSplineCurve_DownCast | | 28 | +from OCC.Core.Geom import Geom_BSplineCurve | 29 | 29 |
| 30 | 30 | from OCC.Display.SimpleGui import init_display | 31 | 31 |
| @@ -64,14 +64,14 @@ def surface_from_curves(): | 64 | 64 | SPL2, | 65 | 65 | GeomFill_StretchStyle) | 66 | 66 |
| 67 | | - SPL3 = Geom_BSplineCurve_DownCast(SPL1.Translated(gp_Vec(10, 0, 0))) | 68 | | - SPL4 = Geom_BSplineCurve_DownCast(SPL2.Translated(gp_Vec(10, 0, 0))) | | 67 | + SPL3 = Geom_BSplineCurve.DownCast(SPL1.Translated(gp_Vec(10, 0, 0))) | | 68 | + SPL4 = Geom_BSplineCurve.DownCast(SPL2.Translated(gp_Vec(10, 0, 0))) | 69 | 69 | # Fill with CoonsStyle | 70 | 70 | aGeomFill2 = GeomFill_BSplineCurves(SPL3, | 71 | 71 | SPL4, | 72 | 72 | GeomFill_CoonsStyle) | 73 | | - SPL5 = Geom_BSplineCurve_DownCast(SPL1.Translated(gp_Vec(20, 0, 0))) | 74 | | - SPL6 = Geom_BSplineCurve_DownCast(SPL2.Translated(gp_Vec(20, 0, 0))) | | 73 | + SPL5 = Geom_BSplineCurve.DownCast(SPL1.Translated(gp_Vec(20, 0, 0))) | | 74 | + SPL6 = Geom_BSplineCurve.DownCast(SPL2.Translated(gp_Vec(20, 0, 0))) | 75 | 75 | # Fill with CurvedStyle | 76 | 76 | aGeomFill3 = GeomFill_BSplineCurves(SPL5, | 77 | 77 | SPL6, | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_load_step_ap203_ocaf.py +1-5Lines changed: 1 addition & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 36 | 36 | _shapes = [] | 37 | 37 |
| 38 | 38 | # create an handle to a document | 39 | | -doc = TDocStd_Document() | 40 | | - | 41 | | -# Create the application | 42 | | -app = XCAFApp_Application.GetApplication() | 43 | | -app.NewDocument(TCollection_ExtendedString("MDTV-CAF"), doc) | | 39 | +doc = TDocStd_Document(TCollection_ExtendedString("pythonocc-doc")) | 44 | 40 |
| 45 | 41 | # Get root assembly | 46 | 42 | shape_tool = XCAFDoc_DocumentTool_ShapeTool(doc.Main()) | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_load_step_with_colors.py +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 | ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. | 17 | 17 |
| 18 | 18 | from OCC.Extend.DataExchange import read_step_file_with_names_colors | 19 | | -from OCC.Display.WebGl import x3dom_renderer | | 19 | +from OCC.Core.Quantity import Quantity_Color, Quantity_TOC_RGB | | 20 | +from OCC.Display.SimpleGui import init_display | 20 | 21 |
| 21 | 22 | filename = '../assets/models/as1-oc-214.stp' | 22 | 23 | shapes_labels_colors = read_step_file_with_names_colors(filename) | | 28 | 29 | # traverse shapes, render in "face" mode | 29 | 30 | for shpt_lbl_color in shapes_labels_colors: | 30 | 31 | shape, label, c = shpt_lbl_color | 31 | | - display.DisplayColoredShape(shape, color=(c.Red(), c.Green(), c.Blue())) | | 32 | + display.DisplayColoredShape(shape, color=Quantity_Color(c.Red(), | | 33 | + c.Green(), | | 34 | + c.Blue(), | | 35 | + Quantity_TOC_RGB)) | 32 | 36 |
| 33 | 37 | start_display() |
Collapse file Copy file name to clipboardExpand all lines: examples/core_modeling_sprocket.py +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -161,14 +161,14 @@ def build_tooth(): | 161 | 161 | arc4 = BRepBuilderAPI_MakeEdge(geomapi_To3d(mirror_profile, plane)).Edge() | 162 | 162 | arc5 = BRepBuilderAPI_MakeEdge(geomapi_To3d(mirror_base, plane)).Edge() | 163 | 163 |
| 164 | | - p4 = Proxy(mirror_base).EndPoint() | 165 | | - p5 = Proxy(inner_arc).StartPoint() | | 164 | + p4 = mirror_base.EndPoint() | | 165 | + p5 = inner_arc.StartPoint() | 166 | 166 |
| 167 | 167 | lin1 = BRepBuilderAPI_MakeEdge(gp_Pnt(p4.X(), p4.Y(), 0), | 168 | 168 | gp_Pnt(p5.X(), p5.Y(), 0)).Edge() | 169 | 169 | arc6 = BRepBuilderAPI_MakeEdge(geomapi_To3d(inner_arc, plane)).Edge() | 170 | 170 |
| 171 | | - p6 = Proxy(inner_arc).EndPoint() | | 171 | + p6 = inner_arc.EndPoint() | 172 | 172 | lin2 = BRepBuilderAPI_MakeEdge(gp_Pnt(p6.X(), p6.Y(), 0), | 173 | 173 | gp_Pnt(p0.X(), p0.Y(), 0)).Edge() | 174 | 174 |
| @@ -322,7 +322,7 @@ def cut_out(base): | 322 | 322 |
| 323 | 323 | geom_outer = GCE2d_MakeCircle(outer).Value() | 324 | 324 | geom_inner = GCE2d_MakeCircle(inner).Value() | 325 | | - Proxy(geom_inner).Reverse() | | 325 | + geom_inner.Reverse() | 326 | 326 |
| 327 | 327 | base_angle = (2. * M_PI) / mounting_hole_count | 328 | 328 | hole_angle = atan(hole_radius / mounting_radius) | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_topology_draft_angle.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 23 | 23 | from OCC.Core.BRep import BRep_Tool_Surface | 24 | 24 | from OCC.Core.TopExp import TopExp_Explorer | 25 | 25 | from OCC.Core.TopAbs import TopAbs_FACE | 26 | | -from OCC.Core.Geom import Geom_Plane_DownCast | | 26 | +from OCC.Core.Geom import Geom_Plane | 27 | 27 | from OCC.Core.TopoDS import topods_Face | 28 | 28 |
| 29 | 29 | from OCC.Display.SimpleGui import init_display | @@ -37,7 +37,7 @@ def draft_angle(event=None): | 37 | 37 | topExp.Init(S, TopAbs_FACE) | 38 | 38 | while topExp.More(): | 39 | 39 | face = topods_Face(topExp.Current()) | 40 | | - surf = Geom_Plane_DownCast(BRep_Tool_Surface(face)) | | 40 | + surf = Geom_Plane.DownCast(BRep_Tool_Surface(face)) | 41 | 41 | dirf = surf.Pln().Axis().Direction() | 42 | 42 | ddd = gp_Dir(0, 0, 1) | 43 | 43 | if dirf.IsNormal(ddd, precision_Angular()): | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_topology_local_ops.py +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 29 | 29 | from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox, BRepPrimAPI_MakePrism | 30 | 30 | from OCC.Display.SimpleGui import init_display | 31 | 31 | from OCC.Core.GCE2d import GCE2d_MakeLine | 32 | | -from OCC.Core.Geom import Geom_Plane_DownCast, Geom_Plane | | 32 | +from OCC.Core.Geom import Geom_Plane, Geom_Plane | 33 | 33 | from OCC.Core.Geom2d import Geom2d_Circle | 34 | 34 | from OCC.Core.GeomAbs import GeomAbs_Arc | 35 | 35 | from OCC.Core.TopTools import TopTools_ListOfShape | @@ -52,7 +52,7 @@ def extrusion(event=None): | 52 | 52 | surf = BRep_Tool_Surface(F) | 53 | 53 |
| 54 | 54 | # Make a plane from this face | 55 | | - Pl = Geom_Plane_DownCast(surf) | | 55 | + Pln = Geom_Plane.DownCast(surf) | 56 | 56 |
| 57 | 57 | # Get the normal of this plane. This will be the direction of extrusion. | 58 | 58 | D = Pln.Axis().Direction() | @@ -261,7 +261,7 @@ def brep_feat_extrusion_protrusion(event=None): | 261 | 261 | F = next(faces) | 262 | 262 | surf1 = BRep_Tool_Surface(F) | 263 | 263 |
| 264 | | - Pl1 = Geom_Plane_DownCast(surf1) | | 264 | + Pl1 = Geom_Plane.DownCast(surf1) | 265 | 265 |
| 266 | 266 | D1 = Pl1.Pln().Axis().Direction().Reversed() | 267 | 267 | MW = BRepBuilderAPI_MakeWire() | @@ -298,7 +298,7 @@ def brep_feat_extrusion_protrusion(event=None): | 298 | 298 | next(faces) | 299 | 299 | F2 = next(faces) | 300 | 300 | surf2 = BRep_Tool_Surface(F2) | 301 | | - Pl2 = Geom_Plane_DownCast(surf2) | | 301 | + Pl2 = Geom_Plane.DownCast(surf2) | 302 | 302 | D2 = Pl2.Pln().Axis().Direction().Reversed() | 303 | 303 | MW2 = BRepBuilderAPI_MakeWire() | 304 | 304 | p1, p2 = gp_Pnt2d(100., 100.), gp_Pnt2d(200., 100.) | |
|