Spanning multiple monitors

Spanning multiple monitors

csalvian
Enthusiast Enthusiast
1,270 Views
13 Replies
Message 1 of 14

Spanning multiple monitors

csalvian
Enthusiast
Enthusiast

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?

Accepted solutions (1)
1,271 Views
13 Replies
Replies (13)
Message 2 of 14

Ed__Jobe
Mentor
Mentor

You posted a lisp program. This is the VBA forum. Are you seeking a vba solution?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 14

csalvian
Enthusiast
Enthusiast

I’d prefer LISP as I’m more familiar with it, but whichever one works the best I guess. 

0 Likes
Message 4 of 14

gabe_o
Participant
Participant

It seems that when running the command, the "screensize" does not get updated correctly after resizing the application and that's why the viewport is not placing correctly. 

govalle2A2ER_0-1700684670944.png

By doubling the size of the width, it works fine for me. 
Just add the following immediately after getting the screen size.

setq ssize (cons (* 2 (car ssize)) (cdr ssize)))

 

Just started on the forums. Any advice is appreciated!
Message 5 of 14

csalvian
Enthusiast
Enthusiast

Yep, that works. The only thing is, the WindowTop and WindowLeft commands seem to leave a gap. Any thoughts on how to get rid of that?

Screenshot 2023-11-22 182318.png

0 Likes
Message 6 of 14

gabe_o
Participant
Participant

The first thing that crossed my mind was that the order of these two need to be swapped.

(vla-put-WindowTop acadObj 0)
(vla-put-WindowLeft acadObj 0)
(vla-put-width acadObj 7680)
(vla-put-height acadObj 2100)

Not sure if the resizing is moving the window. I won't be able to test anything until I'm back in the office Monday. 

Just started on the forums. Any advice is appreciated!
Message 7 of 14

csalvian
Enthusiast
Enthusiast

So it was the order that was causing the problem. But setting the width to 7680 (3840 x 2), the width winds up at about 7666 and there's a gap on one end that screws things up. I'm at a loss.

0 Likes
Message 8 of 14

csalvian
Enthusiast
Enthusiast
Accepted solution

Ok so here's a video explaining how I got this whole process to work. The video is 3 mins long, but worth watching right to the end. I hope this will give Autodesk some motivation to be able to implement this kind of feature into a future version of AutoCAD.,

It's not perfect, I can't zoom in on an area in my titleblock on the right and still maintain my working viewport on the left, but it's not bad.

Message 9 of 14

ВeekeeCZ
Consultant
Consultant

Thank you for sharing. Just recently, I thought I'd look for some script that would expand my C3D across two monitors. It's a pity that Windows/C3D doesn't remember the last position and restore it. So I must stretch the window every morning and now and then when C3D crashes. I am quite happy with just the first 5 lines of yours... Thanks!

Message 10 of 14

gabe_o
Participant
Participant

Glad to see you got it working. Even if lisp alone wasn't enough. I might try to look into that later to see if it is possible using just lisp. I also wonder if it's possible to create an add-in that could allow both the model space and paper space to be open at once. Something to think about.

Just started on the forums. Any advice is appreciated!
Message 11 of 14

csalvian
Enthusiast
Enthusiast
An addon that allows that would be fantastic. My solution works, but stability seems to be a bit of an issue and it has operational issues that I mentioned. A two-window solution would really be what would work the best. Autodesk doesn't seem to want to implement it for some reason.
Message 12 of 14

csalvian
Enthusiast
Enthusiast

I suppose the only other way to do it would be to XREF in the base building plans into two files....one that is the working model space file and one that is the paper space title blocks. The paper space drawing would then also XREF in the model space drawing to view the stuff that I'm working on. Then I could have two instances of AutoCAD running and be able to view the paper space layouts separate from the working model in model space. I've tried this and it does work, but it's a lot more work in the drawing setup and it doesn't update in realtime. You have to tell the xrefs to reload each time you want the paper space view updated.

Message 13 of 14

gabe_o
Participant
Participant

I did think that it would be possible to XREF both files into one and have two viewports but that seemed impractical. When looking at the location of the window, in full screen, the windowTop and windowLeft are set to -8.

gabe_o_0-1701134766152.png

It seems that there is some sort of padding when in full but not when in normal state. The same applies for trying to stretch the window horizontally. There is some padding that won't allow autoCAD to stretch past the width of my monitors -8 pixels on each end. Since vla-put-windowleft/top only accepts whole numbers, there is no way to place it in the upper most corner. 

Just started on the forums. Any advice is appreciated!
0 Likes
Message 14 of 14

csalvian
Enthusiast
Enthusiast

Yeah that's what I was finding too. And yet, the shortcut that I have with DisplayFusion is able to set the window to the full width.

0 Likes