- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have been trying to get AutoCAD to extend the window across two monitors so I can create a working viewport on the main monitor and the other monitor would show my title block. I've been trying to get the following code to work:
(defun C:SPAN ( / ssize sf viewht viewwid xcoord acadObj)
(command "undo" "mark")
(setq acadObj (vlax-get-acad-object))
(vla-put-WindowState acadObj acNorm)
(vla-put-WindowTop acadObj 0)
(vla-put-WindowLeft acadObj 0)
(vla-put-width acadObj 7680)
(vla-put-height acadObj 2100)
(vla-regen (vla-get-activedocument acadObj) acActiveViewport)
(command "zoom" "extents")
(setq ssize (getvar "screensize"))
(setq viewht (getvar "viewsize"))
(setq sf (/ viewht (cadr ssize)))
(setq viewwid (* (car ssize) sf))
(setq xcoord (- (car (getvar "viewctr")) (/ viewwid 4)))
(command "mview" (list xcoord 0) (list (- xcoord (/ viewwid 2)) 23.15))
(command "line" (list (+ xcoord (/ viewwid 2)) 0) (list (+ xcoord (/ viewwid 2)) 23.15) "")
(command "zoom" "extents")
(princ)
)
Everything from the "Zoom extents" down works fine if I reposition and resize the AutoCAD window manually. But if I run the code as-is, I can see it isn't regenerating the display properly and my viewport doesn't get drawn properly.
Here is a video of what is supposed to happen when I span the window manually. You can see that I'm able to draw in the one viewport and it will update the other viewport in realtime (kinda shoots down Autodesk's claim that they can't make this work due to graphic limitations):
Now here's a video showing what happens when I run the above code, without resizing the window manually.
You can see that the code isn't updating the drawing window and is distorting the image, resulting in the viewport and line being drawn in the wrong locations. Does anyone have any idea how to fix this?
Solved! Go to Solution.