using viewports to the modelspace

414 views
Skip to first unread message

Gustavo Meira

unread,
Oct 9, 2015, 1:05:47 PM10/9/15
to python-ezdxf
Well, hi everybody, and first of all, congratulations for the nice lib.

I've been using dxfwrite (also created by Manfred) for while, and now I'm trying to migrate to ezdxf. Everything was doing great, but when I need to use viewports to the model space I'm a bit lost.

Using dxfwrite, it had a viewport entity. I could just configure it and add it to the drawing. So from paperspace I could visualize a piece of my modelspace.

I'd like to know if ezdxf has anything like that. I've noticed the Viewport class (it's a table entry, not an entity), but it doesn't look like what I expected.

Thanks in advace.

Manfred Moitzi

unread,
Oct 9, 2015, 11:13:31 PM10/9/15
to python-ezdxf
Hi Gustavo!

I forgot to implement the VIEWPORT entity in ezdxf and no one missed it until now ;).

I will implement it as soon as i can.

Best regards,
Manfred

Gustavo Meira

unread,
Oct 10, 2015, 10:27:58 AM10/10/15
to Manfred Moitzi, python-ezdxf
Hey, Manfred. Thanks for the response.

All right. My project is pretty dependent on that issue. So I guess I'll have to wait for it :)

Well, if you need any help, mainly for testing, you can count on me. I'm watching the repo.

Regards.

--
You received this message because you are subscribed to a topic in the Google Groups "python-ezdxf" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ezdxf/uZsARqSZPvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ezdxf...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira

Manfred Moitzi

unread,
Oct 11, 2015, 7:47:46 AM10/11/15
to python-ezdxf, manfred...@gmail.com
Hi Gustavo!

First steps are done, VIEWPORT is implemented, sorry no docs for now, but look at the example "ezdxf\examples\viewports_in_paperspace.py" same as for dxfwrite.

Sadly the implementation for DXF version R12 is different to use than the implementation for R2000 and newer, in R12 most of the viewport attributes are stored as extended entity data and can not be accessed like usual DXF attributes.

Please test the actual bitbucket version.

Best regards,
Manfred
To unsubscribe from this group and all its topics, send an email to python-ezdxf+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Gustavo Meira

unread,
Oct 12, 2015, 3:09:31 PM10/12/15
to Manfred Moitzi, python-ezdxf
Hi, Manfred.

The examples were pretty clear. I don't even know how to thank you for quickly implementing it.

I have a project with a batch of integration tests, which generates around 40 DXF files using the viewport feature. They are pretty much the same "simple" use case, with a single viewport to the modelspace, along with some paperspace details.

I did some changes to my "glue logic" to test the new feature, and it worked pretty well.

I've tested  with AC1009, ACAD 2000, ACAD 2004, ACAD 2007 formats, and also with ACAD 2010 and ACAD 2013/2014. I'm not specifying the view_target_point parameter. They all worked fine with the DWG TrueView 2016. Sorry for not finding any bugs :)

I just noticed the difference between the plot configs, that don't allow me to use the "fit content" layout option by default on versions greater than AC1009, but for me it seems a TrueView thing.

Well, thanks a lot. I hope to be able to contribute with the lib in the future.

Manfred
To unsubscribe from this group and all its topics, send an email to python-ezdxf...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira

--
You received this message because you are subscribed to a topic in the Google Groups "python-ezdxf" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ezdxf/uZsARqSZPvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ezdxf...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Gustavo Meira

unread,
Nov 12, 2015, 12:16:22 PM11/12/15
to Manfred Moitzi, python-ezdxf
Hi again. 

I've been resurrecting some tests, and I think these are going to be more helpful :)

I noticed that I can't add viewports to independent layouts. For example, if I create layouts 'layoutA' and 'layoutB', and if I add a different viewports to each one of these layouts, all viewports are present only on the 'Layout1' layout (kind of a default layout).

Well, and while creating more tests to debug this problem, I also noticed that the same behaviour would happen for LWPOLYLINES entities. Also, everytime I try do delete a layout, TrueView 2016 hangs when opening the DXF file (ok, a different problem I believe).

The following code illustrates the problem I have:

    dwg = ezdxf.new('AC1027')
    msp = dwg.modelspace()

    dwg.create_layout("layoutA")
    dwg.create_layout("layoutB")

    layoutA = dwg.layout("layout2")
    layoutA.add_viewport(center=(2.5, 2.5), size=(5, 5), view_center_point=(0, 1), view_height=0.5)

    layoutB = dwg.layout("layout3")
    layoutB.add_viewport(center=(2.5, 7.5), size=(5, 5), view_center_point=(1, 1), view_height=0.5)

    msp.add_lwpolyline([(0, 0), (0, 1), (1, 1), (1, 0)])

    dwg.saveas("multiple_layouts.dxf")

If haven't made any mistakes, I can open issues for these problems. What you guys think?








Manfred Moitzi

unread,
Nov 12, 2015, 11:18:01 PM11/12/15
to python-ezdxf, manfred...@gmail.com
Hi Gustavo!

Your insights are correct, Layouts do not work as they should (just corrected 'layout2' and 'layout3').

The relevant layout structures are set as they should, as far I know, the problem is, that the DXF standard 
does not describe which properties to set for correct layout management. I have to revers engineer this details and
as I see so far I have to start over again. This can take a while!

Best regards, Manfred
Manfred
To unsubscribe from this group and all its topics, send an email to python-ezdxf+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira

--
You received this message because you are subscribed to a topic in the Google Groups "python-ezdxf" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ezdxf/uZsARqSZPvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ezdxf+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira

Manfred Moitzi

unread,
Nov 26, 2015, 2:11:24 AM11/26/15
to python-ezdxf, manfred...@gmail.com
Hi Gustavo!

I created a new drawing in AutoCAD with 2 layouts 'Layout1' and 'Layout2'. Created a viewport on each layout and saved it as mlayouts_2004.dxf (DXF version AC1018).

Every viewport has an owner tag (330) which points to a BLOCK_RECORD which has a name (2) and a pointer to a layout entity (340). VIEWPORT (330) -> BLOCK_RECORD (340) -> LAYOUT

1. Viewport on Layout1: 330 -> *Paper_Space -> Layout1

2. Viewport on Layout2: 330-> *Paper_Space -> Layout1, but the viewport shows up on Layout2

Conclusion: I don't get it!

I will not document the VIEWPORT entity as a supported entity.

Attached mlayouts_2004.dxf for your information, you can create a 'readable' HTML file by "PY -3 -m ezdxf.pp mlayouts_2004.dxf" (on Windows).

For now I am not motivated to invest more time in layout related problems, sorry.

Best regards,
Manfred

Am Donnerstag, 12. November 2015 18:16:22 UTC+1 schrieb Gustavo Meira:
Manfred
To unsubscribe from this group and all its topics, send an email to python-ezdxf+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira

--
You received this message because you are subscribed to a topic in the Google Groups "python-ezdxf" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ezdxf/uZsARqSZPvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ezdxf+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira
mlayouts_2004.dxf

Manfred Moitzi

unread,
Nov 26, 2015, 2:28:44 AM11/26/15
to python-ezdxf, manfred...@gmail.com
And you also can not place any DXF entity on layouts created by ezdxf, they all show up on the first default layout.

Manfred

Gustavo Meira

unread,
Nov 26, 2015, 5:02:29 AM11/26/15
to Manfred Moitzi, python-ezdxf
Hi Manfred.

Thanks anyway for spending some of your time with this issue. I understand that reverse engineering of DXF files is not an easy task.

I'll try something here based on what you have already discovered. If I get something, I'll let you know.

Hope to come back to you soon. 

Manfred
Manfred
To unsubscribe from this group and all its topics, send an email to python-ezdxf...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira

--
You received this message because you are subscribed to a topic in the Google Groups "python-ezdxf" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ezdxf/uZsARqSZPvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ezdxf...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira



--
Gustavo Roberto Nardon Meira

--
You received this message because you are subscribed to a topic in the Google Groups "python-ezdxf" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ezdxf/uZsARqSZPvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ezdxf...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Gustavo Meira

unread,
Nov 26, 2015, 8:28:36 AM11/26/15
to Manfred Moitzi, python-ezdxf
Hi again.

Trying to follow the same path you mentioned (with the DXF you've created), I found some different results, but they're still weird.

I found four VIEWPORT entries, two of them in the BLOCK section and two of them in the ENTITIES section. Both viewports from the BLOCK section had reference to the same BLOCK_RECORD (handle 5D), while the viewports from the ENTITIES section had reference to other BLOCK_RECORD (handle 58). If I resolve these BLOCK_RECORDS' layout (340) I get the two different layouts (handles 5E and 59).

I don't really get how the BLOCK section works, I thought I would be able to see at least an INSERT for one of the VIEWPORTS.

I'll probably come back to this in the future, and if I have something, I bring it to list.

Regards.

Manfred Moitzi

unread,
Nov 27, 2015, 1:39:54 AM11/27/15
to python-ezdxf, manfred...@gmail.com
Hi!

A good hint! Now I know that my implementation of adding entities to layouts is wrong.

I thought all entities of the modelspace and all entities in layouts resides in the ENTITIES section - that is wrong.

The ENTITIES section contains the entities of the modelspace and only the entities of the actual (last used) layout, 
which has always the internal name *Paper_Space, all other entities from other layouts are stored in blocks in the 
BLOCKS section. The block for the actual layout *Paper_Space is always empty.

Step 1: implement the layout entities handling correct

Step 2: try to understand the VIEWPORT entities

Manfred
Manfred
Manfred
To unsubscribe from this group and all its topics, send an email to python-ezdxf+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira

--
You received this message because you are subscribed to a topic in the Google Groups "python-ezdxf" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ezdxf/uZsARqSZPvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ezdxf+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira



--
Gustavo Roberto Nardon Meira

--
You received this message because you are subscribed to a topic in the Google Groups "python-ezdxf" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ezdxf/uZsARqSZPvs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ezdxf+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gustavo Roberto Nardon Meira

Manfred Moitzi

unread,
Nov 27, 2015, 8:39:10 AM11/27/15
to python-ezdxf, manfred...@gmail.com
Hi again!

Step 1 is done, I can create entities on different layouts, but VIEWPORTS still don't work.

Actual version is available at https://bitbucket.org/mozman/ezdxf

Maybe you can do some tests.

Manfred
Reply all
Reply to author
Forward
0 new messages