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 02-20-2009, 08:18 PM   #1
Codi
Veteran
portfolio
Enric Saumell
España
 
Join Date: May 2005
Posts: 47
UVW Xform modifier, how to acces 'Apply to Entire Object'?

Hi,

I'm trying to do a simple script for randomizing the mapping of the selected objects. To do so, the script adds a UVW_Xform modifier to the selected objects and applies a random value to the modifier u and v offsets.
The problem is that I need to enable "Apply to Entire Object" so the modifier changes the whole object mapping, ignoring any possible sub-object selections, but I can't find any property to change this. Is there some way to enable this option in MAXScript?

Thanks.
 
Old 02-20-2009, 08:38 PM   #2
ZeBoxx2
Lord of the posts
 
ZeBoxx2's Avatar
Richard Annema
Caustic Graphics / SplutterFish
Groningen, Netherlands
 
Join Date: Jul 2006
Posts: 1,461
odd how these things are not exposed...

Two options..

A. Max library file
1. Save a 3ds Max file (say, 'uvwxform.max') with the modifier in each of the two states applied to an object/objects.
2. When you need a UVW XForm modifier, merge the object from the library 'uvwxform.max'
3. Grab the modifier from the object
4. Apply to the object of interest.

Which is only really practical if you only need to create new ones, not adjust existing ones (though replaceInstances might help there).

B. ScaryCode
Code:
fn setApplyToEntireObject unwxformmod state = ( -- windows codes local WM_COMMAND = 0x111 -- Windows Message: Command local BN_CLICKED = 0 -- clicky the button notification local BM_SETCHECK = 241 -- checkbutton toggle message ID -- change to modify panel, open the modifier if (GetCommandPanelTaskMode() != #modify) do ( SetCommandPanelTaskMode #modify ) if (modPanel.getCurrentObject() != unwxformmod) do ( modpanel.setCurrentObject unwxformmod ) -- get all the children of the desktop (in case command panel is floating) local desktopHWND = windows.getDesktopHWND() -- get its children local desktopChildren = windows.getChildrenHWND desktopHWND -- let's find that Apply to Entire Object checkbox local ateo_checkbox for child in desktopChildren do ( if (child[5] == "Apply to Entire Object") do ( ateo_checkbox = child ) ) -- not found? uh oh if (ateo_checkbox == undefined) do ( return undefined ) -- otherwise, let's proceed local ateo_checkbox_hwnd = ateo_checkbox[1] local ateo_checkbox_parent = UIAccessor.getParentWindow ateo_checkbox_hwnd local ateo_checkbox_id = UIAccessor.GetWindowResourceID ateo_checkbox_hwnd windows.sendMessage ateo_checkbox_hwnd BM_SETCHECK (if (state) then ( 1 ) else ( 0 )) 0 windows.sendMessage ateo_checkbox_parent WM_COMMAND ((bit.shift BN_CLICKED 16) + ateo_checkbox_id) ateo_checkbox_hwnd -- done OK )


Usage:
Code:
-- <undefined|OK>setApplyToEntireObject uvw_xform_modifier <boolean> -- e.g. setApplyToEntireObject $.modifiers[1] true setApplyToEntireObject $.modifiers[1] false
 
Old 02-20-2009, 09:46 PM   #3
Codi
Veteran
portfolio
Enric Saumell
España
 
Join Date: May 2005
Posts: 47
I will have to go with the ScaryCode™ as I'll have to modify the UVW_XForm modifier values in case the object has one already applied, though I'll give some thought also to your first method using replaceInstances because chances are that I'll need to dig the modifier stack to get the UVW_XForm, and I have no idea how to do it modifiing your sample code
(Wich I tested and works like a charm BTW)

Thanks a bunch
 
Old 02-21-2009, 12:34 AM   #4
ZeBoxx2
Lord of the posts
 
ZeBoxx2's Avatar
Richard Annema
Caustic Graphics / SplutterFish
Groningen, Netherlands
 
Join Date: Jul 2006
Posts: 1,461
cool - glad it works

As for getting the modifier - no need to change the function supplied at all; it's meant to be as abstract as possible so that you can call it on any UVW XForm modifier.

All you have to do is, for example, this:
Code:
for o in (getCurrentSelection()) do ( for theMod in o.modifiers do ( if (classOf theMod == uvw_xform) then ( setApplyToEntireObject theMod true ) ) )


Which basically...
1. Loops over the selection, getting each object
2. Loops over the object's modifiers, getting each modifier
3. Checks whether that modifier is a uvw_xform class modifier
4. Calls the earlier function, feeding it the aforementioned modifier as the modifier for it to adjust.

 
Old 02-21-2009, 10:27 AM   #5
Codi
Veteran
portfolio
Enric Saumell
España
 
Join Date: May 2005
Posts: 47
Duh, of curse. I just need to pass the modifier to the function ...

This is just what I needed, thanks for your time
 
Old 02-21-2009, 10:28 AM   #6
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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 10:23 PM.


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