Exemple #1
0
def getDrawing(InputFile, GrabBlocks):
    try:
        InputString = unicode(open(InputFile).read().decode('utf-8'))
    except:
        sys.exit(0)
    InputStream = StringIO(InputString)
    options = {'grab_blocks': GrabBlocks}
    return Drawing(InputStream, options)
Exemple #2
0
class TestDrawingDXF12withBlocks(unittest.TestCase):
    def setUp(self):
        stream = StringIO(DXF12)
        options = {'grab_blocks': True}
        self.dwg = Drawing(stream, options)

    def test_blocks(self):
        self.assertEqual(len(self.dwg.blocks), 8)

    def test_header_var(self):
        self.assertEqual(self.dwg.header['$ACADVER'], 'AC1009')

    def test_layers(self):
        self.assertEqual(len(self.dwg.layers), 5)

    def test_styles(self):
        self.assertEqual(len(self.dwg.styles), 5)

    def test_linetypes(self):
        self.assertEqual(len(self.dwg.linetypes), 5)

    def test_entities(self):
        self.assertEqual(len(self.dwg.entities), 1)

    def test_iter_entities(self):
        entities = list(self.dwg.entities)
        self.assertEqual(1, len(entities))

    def test_get_entity(self):
        self.assertEqual('INSERT', self.dwg.entities[0].dxftype)

    def test_modelspace(self):
        self.assertEqual(len(list(self.dwg.modelspace())), 1)

    def test_paperspace(self):
        self.assertEqual(len(list(self.dwg.paperspace())), 0)
Exemple #3
0
 def setUp(self):
     stream = StringIO(DXF13)
     options = {'grab_blocks': False}
     self.dwg = Drawing(stream, options)
Exemple #4
0
 def setUp(self):
     stream = StringIO(MINIMALISTIC_DXF12)
     options = {'grab_blocks': True}
     self.dwg = Drawing(stream, options)