Copy / move entities - best approach

613 views
Skip to first unread message

squ...@gmail.com

unread,
Feb 22, 2018, 2:48:04 PM2/22/18
to python-ezdxf
So it should be possible to move entities by changing their position attribute?
What about moving them from paperspace to modelspace? If I change the object.dxf.paperspace attribute I imagine it would cause instability.

So probably better approach is to duplicate the entity in it's new space/position. Is there an easy way to copy all of the other attributes?
For example putting all of the attributes into a list, changing just the position attribute, and then using the list to make a new entity?

Thanks
Roger

Manfred Moitzi

unread,
Feb 22, 2018, 11:22:36 PM2/22/18
to squ...@gmail.com, python-ezdxf
Hi!

Moving entities by changing the location attributes is ok.

Moving entities between layouts (for me layouts are: model space, paper space layouts and block layouts),
is possible but not easy, just changing the paperspace attribute works only in DXF R12.


I will implement a move_to_layout() function, if there is a real world need for that.

A copy() function would be easy except for POLYLINE and INSERT, because this entities
using appended entities, POLYLINE-VERTEX-SEQEND and INSERT-ATTRIB-SEQEND, 
but I think it could be done with reasonable effort.

moving to an other layout: entity.move_to_layout(other_layout)

copying: new_entity = entity.copy(); new_entity.move_to_layout(other_layout)


But also consider model space and block layout units are different from paper space layout units,
and that conversion may often fail, because the documentation in the DXF reference is very shallow.

An idea for user side conversion is to move the entities into a block, and use a block reference (INSERT) with scaling.

regards,
Manfred


--
You received this message because you are subscribed to the Google Groups "python-ezdxf" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-ezdxf+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

squ...@gmail.com

unread,
Feb 22, 2018, 11:36:02 PM2/22/18
to python-ezdxf
Thanks I managed to copy across entities by duplicating their dxf attributes. and in the case of polylines I copied the point list.
I only have text and polylines to copy so was quite easy. Thanks for the extra advice though.

I will try and paste some sample code for this and layout creation when I get back to work on Monday.
Just off home for the weekend (New Zealand gets it first!)
To unsubscribe from this group and stop receiving emails from it, send an email to python-ezdxf...@googlegroups.com.

Manfred Moitzi

unread,
Feb 22, 2018, 11:38:37 PM2/22/18
to squ...@gmail.com, python-ezdxf
I just saw copying attributes already works:

attribs = entity.clone_dxf_attribs()
other_entity.update_dxf_attribs(attribs)


Reply all
Reply to author
Forward
0 new messages