ZoomToObjBB

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  10 October 2012
ZoomToObjBB

Based on a previous thread:
http://forums.cgsociety.org/showthr...ht=zoom+extents

I was expecting this to work?:

viewport.ZoomToBounds false (point3 bmin.x bmin.y 0) (point3 bmax.x bmax.y 0)


MXS chm states:

Quote: The second and third arguments define the bounding region to zoom to.


In context:

global ZoomToObjBB

fn ZoomToObjBB =
(
	nodes = for node in selection where iskindof node GeometryClass collect node
	if nodes.count > 0 do
	(
		view = viewport.activeViewport
		local bmin = [1e9,1e9,0], bmax = [-1e9,-1e9,0]

		gw.setTransform (matrix3 1)
		transPoint = gw.hTransPoint
		for node in nodes do
		(
			mesh = snapshotasmesh node
			for v=1 to mesh.numverts do
			(
				vp = transPoint (GetVert mesh v)
				if vp.x < bmin.x do bmin.x = vp.x
				if vp.x > bmax.x do bmax.x = vp.x
				if vp.y < bmin.y do bmin.y = vp.y
				if vp.y > bmax.y do bmax.y = vp.y
			)
			free mesh
		)
		w = (bmax.x - bmin.x) as integer
		h = (bmax.y - bmin.y) as integer
		print bmin.x
		print bmin.y
		print bmax.x
		print bmax.y
		
		viewport.ZoomToBounds false (point3 bmax.x bmax.y 0) (point3 bmin.x bmin.y 0)
		completeRedraw()
	)
)

ZoomToObjBB()


Guess I'm missing something?!

Thanks,
Mike
 
  10 October 2012
Well first of all "node" and "mesh" are reserved words in MaxScript. You should change those variables.

Second, it seems that gw methods only work inside of view port callbacks now. There's an example at the top here: http://docs.autodesk.com/3DSMAX/15/...mber=d30e689013
__________________
Juan Martinez | Blog | Animator
 
  10 October 2012
Originally Posted by martinez: Well first of all "node" and "mesh" are reserved words in MaxScript. You should change those variables.

they are reserved in global scope only. i like to use reserved words in local scope because the mxs editor nicely colors them for me
 
  10 October 2012
Yep, this is essentially Denis's code, so the local scope is ok as he says.
What got me is that I'm using Max2011, so NO Nitrous is present and hence I don't need to be inside of a callback.
ZoomToBounds doesn't seem to work?
 
  10 October 2012

viewport.ZoomToBounds false selection.min selection.max


That works for me in Max 2011 and 2013. Maybe you can explain what you are trying to accomplish in your script.

Your script evaluates fine for me in 2011. But it looks like you are giving viewport.ZoomToBounds screen space coordinates when it's expecting world coordinates. The results of your bmin and bmax are inconsistent, if you run the script a few times in a row. (Because the screen space is changing of course, but I don't think that's what you want when you are trying to zoom to a location.)


ZoomToObjBB()
121.0
16.0
513.0
384.0

ZoomToObjBB()
178.0
34.0
353.0
221.0

ZoomToObjBB()
-107.0
-250.0
323.0
270.0

ZoomToObjBB()
247.0
194.0
359.0
298.0

ZoomToObjBB()
-10297.0
-13559.0
36465.0
105049.0
__________________
Juan Martinez | Blog | Animator
 
  10 October 2012
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:58 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.