def test_setup(self): dimline = ArcDimension((5, 5), (4, 0), (0, 4), (-4, 0), arc3points=True) dimline._setup() center = dimline.center self.assertAlmostEqual(center[0], 0) self.assertAlmostEqual(center[1], 0)
def test_45deg(self): expected = " 0\nARC\n 62\n7\n 8\nDIMENSIONS\n 10\n0.0\n 20\n0.0\n"\ " 30\n0.0\n 40\n7.07106781187\n 50\n0.0\n 51\n45.0\n 0\n"\ "LINE\n 62\n5\n 8\nDIMENSIONS\n 10\n1.3\n 20\n0.0\n 30\n"\ "0.0\n 11\n7.07106781187\n 21\n0.0\n 31\n0.0\n 0\nLINE\n"\ " 62\n5\n 8\nDIMENSIONS\n 10\n0.919238815543\n 20\n"\ "0.919238815543\n 30\n0.0\n 11\n5.0\n 21\n5.0\n 31\n0.0\n"\ " 0\nTEXT\n 62\n7\n 8\nDIMENSIONS\n 10\n6.94856061401\n"\ " 20\n2.8781880453\n 30\n0.0\n 40\n0.5\n 1\n79\n 50\n-67.5\n"\ " 7\nISOCPEUR\n 72\n1\n 73\n2\n 11\n6.94856061401\n 21\n"\ "2.8781880453\n 31\n0.0\n 0\nINSERT\n 8\nDIMENSIONS\n 2\n"\ "DIMTICK_ARCH\n 10\n7.07106781187\n 20\n0.0\n 30\n0.0\n 41\n"\ "1.0\n 42\n1.0\n 50\n90.0\n 0\nINSERT\n 8\nDIMENSIONS\n"\ " 2\nDIMTICK_ARCH\n 10\n5.0\n 20\n5.0\n 30\n0.0\n 41\n1.0\n"\ " 42\n1.0\n 50\n135.0\n" dimline = ArcDimension(pos=(5,5), center=(0, 0), start=(1, 0), end=(1, 1), ) self.assertSequenceEqual(normalize_dxf_chunk(dimline.__dxf__()), normalize_dxf_chunk(expected))
def test_init(self): dimline = ArcDimension(pos=(5, 5), center=(0, 0), start=(1, 0), end=(1, 1), arc3points=False, dimstyle='default', layer="ARCDIMENSION", roundval=1) self.assertTrue("ARCDIMENSION" in dxfstr(dimline))
def test_45deg(self): expected = " 0\nARC\n 62\n7\n 8\nDIMENSIONS\n 10\n0.0\n 20\n0.0\n"\ " 30\n0.0\n 40\n7.07106781187\n 50\n0.0\n 51\n45.0\n 0\n"\ "LINE\n 62\n5\n 8\nDIMENSIONS\n 10\n1.3\n 20\n0.0\n 30\n"\ "0.0\n 11\n7.07106781187\n 21\n0.0\n 31\n0.0\n 0\nLINE\n"\ " 62\n5\n 8\nDIMENSIONS\n 10\n0.919238815543\n 20\n"\ "0.919238815543\n 30\n0.0\n 11\n5.0\n 21\n5.0\n 31\n0.0\n"\ " 0\nTEXT\n 62\n7\n 8\nDIMENSIONS\n 10\n6.94856061401\n"\ " 20\n2.8781880453\n 30\n0.0\n 40\n0.5\n 1\n79\n 50\n-67.5\n"\ " 7\nISOCPEUR\n 72\n1\n 73\n2\n 11\n6.94856061401\n 21\n"\ "2.8781880453\n 31\n0.0\n 0\nINSERT\n 8\nDIMENSIONS\n 2\n"\ "DIMTICK_ARCH\n 10\n7.07106781187\n 20\n0.0\n 30\n0.0\n 41\n"\ "1.0\n 42\n1.0\n 50\n90.0\n 0\nINSERT\n 8\nDIMENSIONS\n"\ " 2\nDIMTICK_ARCH\n 10\n5.0\n 20\n5.0\n 30\n0.0\n 41\n1.0\n"\ " 42\n1.0\n 50\n135.0\n" dimline = ArcDimension( pos=(5, 5), center=(0, 0), start=(1, 0), end=(1, 1), ) self.assertSequenceEqual(normalize_dxf_chunk(dimline.__dxf__()), normalize_dxf_chunk(expected))
dimline = LinearDimension((-2,3), points, dimstyle='dots2', angle=90.) dimline.set_text(1, 'CATCH') # add dimline as anonymous block dwg.add_anonymous_block(dimline, layer='DIMENSIONS') # add polyline to drawing dwg.add(dxf.polyline(points, color=5)) # There are three dimstyle presets for angular dimension # 'angle.deg' (default), 'angle.rad', 'angle.grad' (gon) # for deg and grad default roundval = 0 # for rad default roundval = 3 # angular dimension in grad (gon) dwg.add(AngularDimension(pos=(18, 5), center=(15, 0), start=(20, 0), end=(20, 5), dimstyle='angle.grad')) # angular dimension in degree (default dimstyle), with one fractional digit dwg.add(AngularDimension(pos=(18, 10), center=(15, 5), start=(20, 5), end=(20, 10), roundval=1)) dwg.add(ArcDimension(pos=(23, 5), center=(20, 0), start=(25, 0), end=(25, 5), dimstyle='dots2')) # RadialDimension has a special tick dimstyles.new("radius", height=0.25, prefix='R=') dwg.add(RadialDimension((20, 0), (24, 1.5), dimstyle='radius')) dwg.save() print("drawing '%s' created.\n" % name)
def test_setup(self): dimline = ArcDimension((5,5), (4,0), (0,4), (-4,0), arc3points=True) dimline._setup() center = dimline.center self.assertAlmostEqual(center[0], 0) self.assertAlmostEqual(center[1], 0)