I'm trying to display rectangles from a dxf file on a device context using ezdxf and wxpython. But this is not displayed with correct scale and seems out of device area.
class draw(wx.Window):
def __init__(self, parent):
wx.Window.__init__(self, parent, -1, (-1, -1), (1000, 650))
self.SetBackgroundColour("#888")
self.CenterOnParent()
self.pen = wx.Pen("#ff0000", 3, wx.PENSTYLE_SOLID)
self.brush = wx.Brush("#ff0", wx.TRANSPARENT)
self.posFrame = wx.StaticText(self, -1, "[0, 0]", (-1, -1), (-1, -1))
self.textFont = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL)
self.posFrame.Show(False)
self.pos = (0, 0)
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, ev):
dc = wx.PaintDC(self)
dc.SetMapMode(wx.MM_TEXT)
dc.SetAxisOrientation(False, True)
dc.SetDeviceOrigin(264800, 745800)
# dc.CalcBoundingBox(270000, 750000)
# dc.SetUserScale(0.008238, 0.005392)
dc.CrossHair(500, 325)
s1 = msp2.query("LWPOLYLINE").entities
self.pen.SetWidth(1)
self.pen.SetColour("#ff0")
dc.SetPen(self.pen)
dc.SetBrush(self.brush)
for x in range(len(s1)):
pts = []
for y in range(len(s1[x])):
coords = s1[x][y]
coordX = coords[0]
coordY = coords[1]
coordZ = coords[2]
coordXYZ = "({}, {}, {})".format(coordX, coordY, coordZ)
# print(coordXYZ)
pts.append((float(coordX), float(coordY)))
dc.DrawPolygon(pts)