Пример #1
0
 def execute(self):
     input_shape = self.input.shape
     
     topo = Topo(input_shape)
     self._n_edges = topo.number_of_edges()
     
     builder = BRepFilletAPI.BRepFilletAPI_MakeChamfer(input_shape)
     
     Map = TDF.TDF_LabelMap()
     itr = TDF.TDF_ChildIterator(self.parent_label, True)
     while itr.More():
         sub_label = itr.Value()
         Map.Add(sub_label)
         itr.Next()
         
     selector = self.selector
     ret = selector.Solve(Map)
     
     if not ret:
         raise Exception("Failed to solve for edge")
         #print "Failed to solve for edge"
     
     nt = TNaming.TNaming_Tool()
     selected_shape = nt.CurrentShape(selector.NamedShape())
     
     selected_edge = TopoDS.TopoDS().Edge(selected_shape)
     
     try:
         face = Topo(input_shape).faces_from_edge(selected_edge).next()
     except RuntimeError:
         raise #not sure how to handle this
     size = self.size
     builder.Add(size, size, selected_edge, face)
     
     self.update_naming(builder)
     return builder.Shape()
Пример #2
0
aMap = TDF.TDF_LabelMap()
aMap.Add(box_label)
itr = TDF.TDF_ChildIterator(box_label, True)
while itr.More():
    sub_label = itr.Value()
    aMap.Add(sub_label)
    itr.Next()

#
#Solve for the selected edge
#
ok = selector.Solve(aMap)
print "solve OK", ok

#
#Extract the selected edge
#
nt = TNaming.TNaming_Tool()
shape = nt.CurrentShape(selector.NamedShape())

#display them together
display.DisplayShape(shape)

#Make the box transparent, so it's easier to see the selected edge
ctx = display.Context
ais_shape = AIS.AIS_Shape(box2).GetHandle()
ctx.SetTransparency(ais_shape, 0.8, True)
ctx.Display(ais_shape)

start_display()