>
Hi Bryan,
You know I really fancy your involvement in pythonOCC, but I ask you
kindly to be very precise in replying.
Thing is that noisy and incorrect statements like below than need
correction etc etc.
> The documentation is primarily meant for the Windows platform, so
> you'll have to use some sort of CHM-viewer thingy.
Cheers mate!
Oh, btw; I noticed your interest in BrepFeat.
A neat little trick is to use ShapeFix before performing a BrepFeat.
That way you're wires are ordered in the correct sense, so you don't
have to handle it yourself ( I dont get much joy out of that, and I'm
lazy, so I like it ;')
Here's a nice function to make an open cube that does this.
def open_unit_cube(ratio, scale=None):
S = BRepPrimAPI_MakeBox(1.,1.,1.).Shape()
topo = Topo(S)
def make_wire(face, ratio):
# 0.5 should be an additional argument: ratio from 0 to 1
topo = Topo(face)
wire = topo.wires().next()
edges, verts = [], []
te, bt = TopExp(), BRep_Tool()
_verts = [bt.Pnt(v) for v in
topo.ordered_vertices_from_wire(wire)]
center_vec = gp_Vec(_verts[0].XYZ()) +
gp_Vec(_verts[0],_verts[2])/2.
center_pnt = gp_Pnt(center_vec.XYZ())
for e in topo.ordered_edges_from_wire(wire):
verts.append([ bt.Pnt(te.FirstVertex(e)),
bt.Pnt(te.LastVertex(e))
]
)
edges.append(e)
_wire = BRepBuilderAPI_MakeWire()
for edg in verts:
pnts = []
for v in edg:
vec = gp_Vec(v.XYZ()) + gp_Vec(v, center_pnt)*ratio
pnts.append(gp_Pnt(vec.XYZ()))
_wire.Add(BRepBuilderAPI_MakeEdge(pnts[0], pnts[1]).Edge())
_wire.Build()
return _wire.Wire()
def prism(_shape, _face, _wire):
surf = BRep_Tool().Surface(_face)
pln = Handle_Geom_Plane().DownCast(surf).GetObject()
D2 = pln.Pln().Axis().Direction().Reversed()
MKF2 = BRepBuilderAPI_MakeFace()
MKF2.Init(surf,False)
MKF2.Add(_wire)
MKF2.Build()
FP = MKF2.Face()
BRepLib().BuildCurves3d(FP)
sfs = ShapeFix_Shape()
sfs.Init(FP)
sfs.Perform()
FP = TopoDS.TopoDS().Face(sfs.Shape())
MKP2 = BRepFeat_MakePrism(_shape,FP,_face,D2,0,True)
MKP2.PerformThruAll()
return MKP2.Shape()
vert = topo.vertices().next()
for face in topo.faces_from_vertex(vert):
_wire = make_wire(face, ratio)
S = prism(S, face, _wire)
if scale is not None:
print 'run scale', scale
tr = gp_Trsf()
tr.SetScale(gp_Pnt(), scale)
gtr = gp_GTrsf()
gtr.SetTrsf(tr)
return BRepBuilderAPI_Transform(S, tr, False).Shape()
else:
return S
How is the shape mating coming along?
Any screenshots to share buddy ;')
Cheers,
-jelle
_______________________________________________
Pythonocc-users mailing list
[email protected]
https://mail.gna.org/listinfo/pythonocc-users