def create_collection(self): collection = CPolylineCollection() p1 = CPolyline( name = "POLY1" , init_points = [(0,10) , (1,11) , (2,12)]) p2 = CPolyline( name = "POLY2" , init_points = [(0,100) , (10,110) , (20,120)]) collection.addPolyline( p1 ) collection.addPolyline( p2 ) tail = p1[-1] self.assertEqual( tail , (2,12)) self.assertEqual(p1.getName() , "POLY1") tail = p2[-1] self.assertEqual( tail , (20,120)) self.assertEqual(p2.getName() , "POLY2") return collection
def addPolyline(self , polyline , name = None): if not isinstance(polyline , CPolyline): polyline = CPolyline( init_points = polyline , name = name) else: if not name is None: raise ValueError("The name keyword argument can only be supplied when add not CPOlyline object") name = polyline.getName() if name and name in self: raise KeyError("The polyline collection already has an object:%s" % name) if polyline.isReference(): self._add_polyline( polyline , False) else: polyline.convertToCReference( self ) self._add_polyline( polyline , True)
def addPolyline(self, polyline, name=None): if not isinstance(polyline, CPolyline): polyline = CPolyline(init_points=polyline, name=name) else: if not name is None: raise ValueError( "The name keyword argument can only be supplied when add not CPOlyline object" ) name = polyline.getName() if name and name in self: raise KeyError("The polyline collection already has an object:%s" % name) if polyline.isReference(): self._add_polyline(polyline, False) else: polyline.convertToCReference(self) self._add_polyline(polyline, True)
def test_name(self): p1 = CPolyline() self.assertTrue(p1.getName() is None) p2 = CPolyline(name="Poly2") self.assertEqual(p2.getName(), "Poly2")
def test_name(self): p1 = CPolyline() self.assertTrue( p1.getName() is None ) p2 = CPolyline( name = "Poly2" ) self.assertEqual( p2.getName() , "Poly2")