How to restore viewport size with maxscript command?

How to restore viewport size with maxscript command?

maxyweb
Contributor Contributor
1,933 Views
16 Replies
Message 1 of 17

How to restore viewport size with maxscript command?

maxyweb
Contributor
Contributor

How to restore viewport size with maxscript command?
I can hide-show Time Slider or hide-show Ribbon and this will restore the viewports, but this is bad option. Is there a command that restores viewports?

Thanks!

0 Likes
1,934 Views
16 Replies
Replies (16)
Message 2 of 17

denisT.MaxDoctor
Advisor
Advisor

How did this happen? What did you do to shift (scale) it like that?

0 Likes
Message 3 of 17

MartinBeh
Advisor
Advisor

@denisT.MaxDoctor  schrieb:

How did this happen? What did you do to shift (scale) it like that?


Probably related to https://forums.autodesk.com/t5/3ds-max-programming/how-to-create-floating-viewport-with-specific-siz...

 

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

denisT.MaxDoctor
Advisor
Advisor

denisTMaxDoctor_0-1721805521991.png

 

This is the main panel as I see it... something needs to be done to screw it like that.

 

0 Likes
Message 5 of 17

maxyweb
Contributor
Contributor

Yes, I reduce the base viewport to the required size of 800x600, take a screenshot and it works fine, there is a problem that the viewport does not always return to the original size. The question was: is there a maxscript command that updates the size of viewports as does changing the UI configuration. For example, turning on or off the Time Slider restores the viewport size, but writing macros.run "Customize User Interface" "UI_TimeSlider_Toggle" into the script is a clumsy solution

0 Likes
Message 6 of 17

denisT.MaxDoctor
Advisor
Advisor

@maxyweb wrote:

Yes, I reduce the base viewport to the required size of 800x600, take a screenshot and it works fine, there is a problem that the viewport does not always return to the original size. 


Yeah, I was expecting something like that...

 

"

- How do you fix a TV?
- What's wrong with it?
- The sound's gone.
- What do you mean, it's gone?
- I was watching TV, picking at my ear with a screwdriver, and the sound's gone...

"
😁

Message 7 of 17

maxyweb
Contributor
Contributor

ok, let's chalk it up to translation difficulties
I suspect the joke is funny)

0 Likes
Message 8 of 17

denisT.MaxDoctor
Advisor
Advisor

I still don't understand why you try to scale the viewport to take a snapshot of a given size... take a DIB with the current or larger size and scale the image.

 

 

src=gw.getViewportDib()
trg = bitmap 800 600
copy src trg
display trg

 

 

0 Likes
Message 9 of 17

maxyweb
Contributor
Contributor

Because if the viewport does not have a 4x3 aspect ratio, and most often this is the case, then the screenshot turns out to be stretched vertically.
like in this example:
src=gw.getViewportDib()
trg = bitmap 800 600
copy src trg
display trg

In order to get the correct screenshot, I first need to make the viewport aspect ratio 4x3 (800x600)

0 Likes
Message 10 of 17

denisT.MaxDoctor
Advisor
Advisor

@maxyweb wrote:

 

In order to get the correct screenshot, I first need to make the viewport aspect ratio 4x3 (800x600)


so what? just do it:

 

(
	
	size = [800, 600]
	ratio = size.x / size.y

	src=gw.getViewportDib()
	
	if (1.0 * src.width / src.height) != ratio do
	(
		if (src.width > src.height) then
		(
			h = src.height
			w = int (h * ratio)
			bb = box2 ((src.width - w)/2) 0 w h
		)
		else
		(
			w = src.width
			h = int (w / ratio)
			bb = box2 0 ((src.height - h)/2) 0 w h
		)

		tmp = bitmap w h
		pastebitmap src tmp bb [0,0]
		
		src=tmp
	)

	trg = bitmap size.x size.y
	copy src trg
	display trg
)

 

 

0 Likes
Message 11 of 17

maxyweb
Contributor
Contributor

In this case, some of the information is cut off and it is not clear from which camera the screenshot was takenVoPqXMEhIz.png

0 Likes
Message 12 of 17

denisT.MaxDoctor
Advisor
Advisor

That's it! You're too picky! You're on your own from here...

😎

0 Likes
Message 13 of 17

maxyweb
Contributor
Contributor

Yes, there is such a thing)
That's why I didn't ask a complex question, I asked a simple one.
I'm sure there is a simple solution to restore the viewport size, but I haven't found it, and since not everyone needs it, not everyone knows.
There was hope)

0 Likes
Message 14 of 17

denisT.MaxDoctor
Advisor
Advisor

@maxyweb wrote:

Yes, there is such a thing)
That's why I didn't ask a complex question, I asked a simple one.
I'm sure there is a simple solution to restore the viewport size, but I haven't found it, and since not everyone needs it, not everyone knows.


I wrote dozens of tools similar to that in my practice...

your problem is that you went in the wrong direction from the beginning, but I couldn't convince you. So ... you're on your own now.

0 Likes
Message 15 of 17

maxyweb
Contributor
Contributor

I have been watching you for a long time, starting with CGtalk, and I admit that you are the most experienced expert on this topic, I especially appreciate your desire to share your knowledge. But no one can know absolutely everything. Perhaps I chose the wrong path, but it works, although not exactly as I would like. In any case, thank you for being there, respect! )

0 Likes
Message 16 of 17

denisT.MaxDoctor
Advisor
Advisor

@maxyweb wrote:

But no one can know absolutely everything. 


at least how to update the view panel with a single command, I know for sure....

 

denisTMaxDoctor_0-1721855043926.gif

 

 

0 Likes
Message 17 of 17

maxyweb
Contributor
Contributor

Let it remain a secret, otherwise it will be boring )

0 Likes