Skip to content
Advertisement

ezDXF: Can i set a text style inside a BLOCK?

When I try to set up a text style inside a BLOCK, TrueView stops with an error. If I remove the style line the DXF is accepted

doc = ezdxf.new(dxfversion="AC1024")
#...
device = doc.blocks.new(name='device')
device.add_text("eBCON",
         dxfattribs={
            #'style': 'LiberationSerif', # 
             'height': 8}
         ).set_pos((marg+margxdev+2, marg+margydev+2), align='LEFT')

Its an Autocad limitation or a non implemented feature in ezDXF?

I have no full Autocad available for checking…

Advertisement

Answer

Any text style you want to use must be defined in the DXF document’s style table. The only text style defined by default is Standard. I suspect you copied your code from an example or the documentation without reading the rest.

The part you’re missing is the setup=True argument in the ezdxf.new() function:

doc = ezdxf.new(dxfversion="AC1024", setup=True)

This creates some text styles, including LiberationSerif.

Tutorial for the TEXT entity: https://ezdxf.mozman.at/docs/tutorials/text.html

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement