Rotate a Raster Image reference around different base_point than the insertion coordinates?

30 views
Skip to first unread message

cjp_uni6

unread,
Mar 31, 2020, 2:16:55 PM3/31/20
to python-ezdxf
Thank you in advance for reading my question.

I am inserting an image to a doc at the appropriate coordinates to coincide with the rest of the 3d model - (x0, y0):

msp.add_image(insert=(x0, y0), size_in_units=size, image_def=img_def, rotation=45)

My understanding is that the image (block) reference rotation's base point will now be centered around that insert position. 

What I would like to do is insert the image as above at the specified point (x0, y0), but apply the 45 degree rotation around a new position (x1, y1).

I tried setting the img_def base_point to that new value (x1, y1) but that does not give me the desired results. Can somebody help me figure out what I'm missing in order to achieve this? Very much appreciated.

Manfred Moitzi

unread,
Mar 31, 2020, 10:22:11 PM3/31/20
to python-ezdxf
The block reference rotation poit is defined by the BLOCK base_point my_block = doc.blocks.new('My_Block', base_point=(0, 0), the INSERT entity (block reference) places the block ant the insert location of the INSERT entity.

You have the create a block and add the image with the image rotation point located in then BLOCK base_point.

cjp_uni6

unread,
Apr 1, 2020, 11:26:08 AM4/1/20
to python-ezdxf
This makes sense, thank you very much Manfred!  

Now the only thing I am missing is how to add an image to the center(?) of a block reference.   Can I insert at the coordinates (0,0) relative to the block, or somehow default the block to simply take up the dimensions of my added image?  

Previously, I had added the image at the center by inserting at the bottom left corner of the image.  When I attempt to do that for the block the positioning is off.  I couldn't find anything about a default insertion point when adding images to blocks.

rotated_block = doc.blocks.new("rotated_block", base_point=(0,0))

rotated_block.add_image(insert=(?,?), size_in_units=size, image_def=img_def, rotation=rotation)

msp.add_blockref("rotated_block", img_coordinates_bottom_left_corner)

Thank you again for your support this is greatly appreciated.
Reply all
Reply to author
Forward
0 new messages