UVW Xform modifier, how to acces 'Apply to Entire Object'?

Become a member of the CGSociety

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

Thread Tools Display Modes
  02 February 2009
UVW Xform modifier, how to acces 'Apply to Entire Object'?


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?

  02 February 2009
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

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


-- <undefined|OK>setApplyToEntireObject uvw_xform_modifier <boolean>
-- e.g.
setApplyToEntireObject $.modifiers[1] true
setApplyToEntireObject $.modifiers[1] false
  02 February 2009
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
  02 February 2009
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:

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.

  02 February 2009
Duh, of curse. I just need to pass the modifier to the function ...

This is just what I needed, thanks for your time
  02 February 2009
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
Society of Digital Artists

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

All times are GMT. The time now is 08:17 PM.

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