def allow(self, doc, obj, sub): # pylint: disable=unused-argument PathLog.debug("obj: {} sub: {}".format(obj, sub)) if hasattr(obj, "Shape") and sub: shape = obj.Shape subobj = shape.getElement(sub) return drillableLib.isDrillable(shape, subobj, vector=None) else: return False
def allow(self, doc, obj, sub): # pylint: disable=unused-argument PathLog.debug("obj: {} sub: {}".format(obj, sub)) if not hasattr(obj, "Shape") and sub: return False shape = obj.Shape subobj = shape.getElement(sub) if subobj.ShapeType not in ["Edge", "Face"]: return False return drillableLib.isDrillable(shape, subobj, vector=None)
def test10(self): """Test isDrillable""" # Invalid types candidate = self.obj.getSubObject("Vertex1") self.assertRaises( TypeError, lambda: drillableLib.isDrillable(self.obj.Shape, candidate)) # # partial cylinder # candidate = self.obj.getSubObject("Face10") # self.assertRaises( # TypeError, lambda: drillableLib.isDrillable(self.obj.Shape, candidate) # ) # Test cylinder faces # thru-hole candidate = self.obj.getSubObject("Face25") # Typical drilling self.assertTrue(drillableLib.isDrillable(self.obj.Shape, candidate)) # Drilling with smaller bit self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, tooldiameter=20)) # Drilling with bit too large self.assertFalse( drillableLib.isDrillable(self.obj.Shape, candidate, tooldiameter=30)) # off-axis hole candidate = self.obj.getSubObject("Face42") # Typical drilling self.assertFalse(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # Passing explicit vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=App.Vector(0, 1, 0))) # Drilling with smaller bit self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, tooldiameter=10, vector=App.Vector(0, 1, 0))) # Drilling with bit too large self.assertFalse( drillableLib.isDrillable(self.obj.Shape, candidate, tooldiameter=30, vector=App.Vector(0, 1, 0))) # ellipse hole candidate = self.obj.getSubObject("Face20") # Typical drilling self.assertFalse(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertFalse( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # raised cylinder candidate = self.obj.getSubObject("Face30") # Typical drilling self.assertFalse(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertFalse( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # cylinder on slope candidate = self.obj.getSubObject("Face26") # Typical drilling self.assertTrue(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # Circular Faces candidate = self.obj.getSubObject("Face51") # Typical drilling self.assertTrue(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # Passing explicit vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=App.Vector(0, 0, 1))) # Drilling with smaller bit self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, tooldiameter=10)) # Drilling with bit too large self.assertFalse( drillableLib.isDrillable(self.obj.Shape, candidate, tooldiameter=30)) # off-axis circular face hole candidate = self.obj.getSubObject("Face54") # Typical drilling self.assertFalse(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # Passing explicit vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=App.Vector(0, 1, 0))) # raised face candidate = self.obj.getSubObject("Face45") # Typical drilling self.assertTrue(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # interrupted Face candidate = self.obj.getSubObject("Face46") # Typical drilling self.assertFalse(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertFalse( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # donut face candidate = self.obj.getSubObject("Face44") # Typical drilling self.assertTrue(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # Test edges # circular edge candidate = self.obj.getSubObject("Edge53") # Typical drilling self.assertTrue(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # Passing explicit vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=App.Vector(0, 0, 1))) # Drilling with smaller bit self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, tooldiameter=10)) # Drilling with bit too large self.assertFalse( drillableLib.isDrillable(self.obj.Shape, candidate, tooldiameter=30)) # off-axis circular edge candidate = self.obj.getSubObject("Edge72") # Typical drilling self.assertFalse(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # Passing explicit vector self.assertTrue( drillableLib.isDrillable(self.obj.Shape, candidate, vector=App.Vector(0, 1, 0))) # incomplete circular edge candidate = self.obj.getSubObject("Edge108") # Typical drilling self.assertFalse(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertFalse( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None)) # elliptical edge candidate = self.obj.getSubObject("Edge54") # Typical drilling self.assertFalse(drillableLib.isDrillable(self.obj.Shape, candidate)) # Passing None as vector self.assertFalse( drillableLib.isDrillable(self.obj.Shape, candidate, vector=None))