2

I have some simple text I want to place in my dxf, like this:

mtext = msp.add_mtext("TEXT TEST", dxfattribs={'style': 'OpenSans'})

I want to insert this text in x=1 and y=1 location in my dxf.

This is what i tried:

mtext.dxf.insert([1,1,0])

But I get error:

mtext.dxf.insert([1,1,0])
TypeError: 'Vector' object is not callable

Any help in resolving this is appreciated.

Edit:

When working with single line text like:

mtext = msp.add_text("TEXT TEST").set_pos((1, 2),align='MIDDLE_RIGHT')

Everything works fine, but I still need to have multiline text written.

user2727167
  • 428
  • 1
  • 3
  • 16

1 Answers1

1

All DXF attributes inside the MText.dxf namespace act like regular object attributes, in this case setting the MText.dxf.insert attribute looks like this:

mtext.dxf.insert = (1, 1, 0)

The extended placement method is called MText.set_location():

mtext.set_location(insert=(1, 1, 0), rotation=0, attachment_point=1)

For more information look at the documentation or the MTEXT tutorial.

user2727167
  • 428
  • 1
  • 3
  • 16
mozman
  • 2,001
  • 8
  • 23