CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 10-05-2012, 04:34 PM   #1
MikeOwen
Frequenter
portfolio
Mike Owen
London, United Kingdom
 
Join Date: Nov 2004
Posts: 131
ZoomToObjBB

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

I was expecting this to work?:

Code:
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:

Code:
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
 
Old 10-06-2012, 11:33 PM   #2
martinez
Expert
 
martinez's Avatar
portfolio
Juan Martinez
Animator
Verse, Inc
Dallas, USA
 
Join Date: Feb 2002
Posts: 206
Send a message via ICQ to martinez Send a message via AIM to martinez
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
 
Old 10-07-2012, 02:56 AM   #3
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,330
Send a message via ICQ to denisT
Quote:
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
 
Old 10-07-2012, 09:05 AM   #4
MikeOwen
Frequenter
portfolio
Mike Owen
London, United Kingdom
 
Join Date: Nov 2004
Posts: 131
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?
 
Old 10-07-2012, 05:16 PM   #5
martinez
Expert
 
martinez's Avatar
portfolio
Juan Martinez
Animator
Verse, Inc
Dallas, USA
 
Join Date: Feb 2002
Posts: 206
Send a message via ICQ to martinez Send a message via AIM to martinez
Code:
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.)

Code:
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
 
Old 10-07-2012, 05:16 PM   #6
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 11:40 AM.


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