How to create floating viewport with specific size

How to create floating viewport with specific size

maxyweb
Contributor Contributor
1,035 Views
11 Replies
Message 1 of 12

How to create floating viewport with specific size

maxyweb
Contributor
Contributor

(maxscript) how to create floating viewport with specific size like 800x600?

actionMan.executeAction -891545229 "0" creates window (maybe there is a more elegant way)
question - how to set window size?
Thanks!

0 Likes
1,036 Views
11 Replies
Replies (11)
Message 2 of 12

denisT.MaxDoctor
Advisor
Advisor
(
	vp_id = #Floating_ViewPanel_1
	ViewPanelManager.SetFloatingViewPanelVisibility vp_id on

	w = windows.getchildhwnd 0 "Floating Viewport - 1"
	b = windows.getwindowpos w[1] removeUIScaling:on
	b.w = 800
	b.h = 600
	windows.setwindowpos w[1] b on applyUIScaling:on
)
0 Likes
Message 3 of 12

maxyweb
Contributor
Contributor

It works very inaccurately. Instead of 800x600, I get 785x563 floating viewport, but I need the exact size

0 Likes
Message 4 of 12

denisT.MaxDoctor
Advisor
Advisor

@maxyweb wrote:

It works very inaccurately. Instead of 800x600, I get 785x563 floating viewport, but I need the exact size


This happened because you asked the question "inaccurately". The floating viewport (window) is exactly 800x600. 

Now think how much you need to add to the window size to make its client area the size you need.

0 Likes
Message 5 of 12

maxyweb
Contributor
Contributor

I don't understand what can be done here to get the exact viewport size of 800x600, besides, it most likely also depends on UIScaleFactor

mMrz5BoNEi.png

0 Likes
Message 6 of 12

MartinBeh
Advisor
Advisor

You could try to create a window of size 815x637 to compensate for the extra space?

Or temporarily disable any UI scaling on the Windows OS level, just to make sure this does not interfere - and if that solves it, maybe we can use the UI scaling factor in getting the size right?

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
0 Likes
Message 7 of 12

maxyweb
Contributor
Contributor

At a minimum, the height of the tittlebar depends on the UI scaling on the Windows OS level, 100% tittlebar=28, 125% tittlebar=31 etc

0 Likes
Message 8 of 12

denisT.MaxDoctor
Advisor
Advisor

Provide a picture that illustrates the specific area you would like to have a certain size.

 

Do you need this size with or without the scaling factor?

 

 

 

 

(
	vp_id = #Floating_ViewPanel_1
	ViewPanelManager.SetFloatingViewPanelVisibility vp_id on

	w = windows.getchildhwnd 0 "Floating Viewport - 1"
	b = windows.getwindowpos w[1] removeUIScaling:on
	b.w = 800
	b.h = 600
	windows.setwindowpos w[1] b on ----- applyUIScaling:on --- don't use 
)

 

 

 

This makes the floating window exactly 800x600 pixels without any scaling factor.

 

 

By the way, why do you need the exact size for a floating window in the first place?

0 Likes
Message 9 of 12

maxyweb
Contributor
Contributor

I don't know what I'm doing wrong, but I get 786x593, considering that system Windows scale is 100%.
I need to make a screenshot of 800x600 exactly using maxscript.

Windows scale can be from 100% to 200%

 

I can take a screenshot by changing the size of the main viewport, but its size does not always return to the original, I asked about this in the neighboring topics

0 Likes
Message 10 of 12

MartinBeh
Advisor
Advisor

This tool worked for me: https://www.brianapps.net/sizer4/

Open a floating viewport, then invoke the tool and set the window to 800x600 - a screenshot of the window was exactly that size.

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
0 Likes
Message 11 of 12

maxyweb
Contributor
Contributor

This may be an interesting and practical solution, but it doesn't suit me, I need to take a screenshot using maxscript and it's a negligibly small part of the script. I have a working solution, but it's not smooth enough.

0 Likes
Message 12 of 12

denisT.MaxDoctor
Advisor
Advisor

Simply grab a viewport using the built-in MAX methods and save the bitmap image at the resolution you want.

0 Likes