Teigha.GraphicsSystem.Device Error
I tried to run the code in the blog below, but I get a 'System.AccessViolationException' error at dev.Add (view); (Line 140)
In AutoCAD it runs fine.
Is there any workaround?
https://through-the-interface.typepad.com/through_the_interface/2007/04/taking_a_snapsh_1.html
0
Comments
-
[CommandMethod("TESTDEV", CommandFlags.Modal)] public void TestDevice() { Document document = Application.DocumentManager.MdiActiveDocument; Manager manager = document.GraphicsManager; using Device device = manager.CreateAutoCADOffScreenDevice(); using View view = device.CreateView(); device.Add(view); device.OnSize(new Size(800, 600)); var p0 = new Point3d(0, 0, 0); var p1 = new Point3d(200, 200, 0); using (var line = new Line(p0, p1) {ColorIndex = 2, LineWeight = LineWeight.LineWeight000}) { view.Add(line); } view.ZoomExtents(p0, p1); device.Update(); using (Bitmap bitmap = view.GetSnapshot(new Rectangle(0, 0, 800, 600))) { bitmap.Save(@"C:\Temp\1.png"); } }
0