[Python] Getting entities of viewports

Discussão em 'Python' iniciado por Stack, Fevereiro 10, 2025.

  1. Stack

    Stack Membro Participativo

    I have a problem with getting entities which remain inside viewports in paperspace.

    p1 point is left bottom corner, p2 point is right top corner. When I plot line from p1 to p2 with the following code I get the following result as a picture of Autocad screen which seems there is an offset along x and y axis. Can anyone help me?

    for vp in layout.viewports():
    xm, ym, zm = vp.dxf.view_center_point
    center = vp.dxf.center
    w = int(vp.dxf.width)
    h = int(vp.dxf.height)
    h2 = int(vp.dxf.view_height)
    w2 = h2/h*w

    p1 = xm - w2/2, ym - h2/2
    p2 = xm + w2/2, ym + h2/2

    msp.add_line(start=p1, end=p2, dxfattribs={'layer': 'dijar'})


    enter image description here
    autocad screen

    Continue reading...

Compartilhe esta Página