This page was generated from unit-4.4-occ/workplane.ipynb.

4.4.2 WorkplanesΒΆ

Workplanes allow 2D construction on planes in 3D space.

[1]:
from netgen.occ import *
from netgen.webgui import Draw as DrawGeo
[2]:
wp = WorkPlane()
wp.Rectangle(5,2)
face = wp.Face()
DrawGeo(face);

A workplane is defined by a local coordinate system given by an 'Axes' object. This is specified by its origin, the normal vector to the plane, and the horizontal direction (i.e. the local x direction).

[3]:
f1 = WorkPlane(Axes((0,0,0), n=Z, h=X)).Rectangle(2,1).Face()
f2 = WorkPlane(Axes((0,1,0), n=-Y, h=X)).Rectangle(2,1).Face()
f3 = WorkPlane(Axes((0,0,0), n=X, h=Y)).Rectangle(1,1).Face()
DrawGeo (f1+f2+f3);

The workplane stores the current position and direction. With Line we draw a straight line of given length in the current direction, with Arc we draw a tangential arc of given radius and angle.

[4]:
wp = WorkPlane()
for i in range(6):
    wp.Line(1).Rotate(60)
wp.MoveTo(3,0)
for i in range(6):
    wp.Line(0.6).Arc(0.4, 60)
face = wp.Face()
DrawGeo(face);

We can draw several wires. Holes a defined by reveriting the orientation of an wire:

[5]:
wp=WorkPlane().RectangleC(2,1) \
    .Circle(0.5,0,0.2).Reverse() \
    .Circle(-0.5,0,0.2).Reverse()
DrawGeo(Compound(wp.Wires()))
DrawGeo(wp.Face());

Faces can be extruded

[6]:
face = WorkPlane().RectangleC(2,1).RectangleC(1.8,0.8).Reverse().Face()
frame = face.Extrude(1)
DrawGeo(frame);

and also revolved:

[7]:
face = WorkPlane().MoveTo(10,0).Line(18).Arc(2,90).Line(6).Arc(2,90) \
    .Line(18).Rotate(90).Line(2).Rotate(90).Line(10) \
    .Arc(3,-180).Line(10).Close().Face()
p = face.Revolve(Axis((0,0,0),Y),180)
DrawGeo(p);
[ ]: