PDA

View Full Version : how to copy modifiers with all data?


Dontnoun
12-10-2008, 05:35 PM
I got a problem,like this
- Create a box, then copy it so you have 2 box
- add an "edit poly" modifier and extrude some faces on first box.
- copy "edit poly" modifier from first box stack to second box

now you see the second box will have extrusions as well.

Is this possible with maxScript?

I have tried this:

mod=box01.modifiers[1]
addModifiers box02 mod

This will apply the modifier on the other box with the same settings but the extrusions are gone

any one can tell me how to do that with maxscript,thanks lot!!!

PEN
12-10-2008, 08:36 PM
For some unknown reason you can't do this.

scrimski
12-10-2008, 09:22 PM
For some unknown reason you can't do this.Any idea for a workaround?

PEN
12-11-2008, 01:46 AM
Well you can get the vert positions and apply those directly. But dealing with changes to vert counts I'm not sure what you can do.

ZeBoxx2
12-11-2008, 03:22 AM
your best bet is to poke at a plugin programmer and see if the methods used in the context menu are exposed via the 3ds Max API/SDK at all.. and then have them expose that to maxscript.

--------------------------------------------------

I did have a try with UIAccessor bits, but various areas are just too klunky to be figuring out.. from having to figure out mouse coordinates within the client area of the modifier list to make sure a right-click event is sent over the correct modifier, to getting the modifier list to scroll (and detecting if it -is- scrollable, etc. etc.), to clicking an item in the context menu.

I gave up after noticing that complexity.. as it stands, it will happily copy/paste the top-most modifier of object A to object B via the UI.. but that won't do you any good if you need a different modifier.. especially if the modifier list gets long and starts scrolling.
( clicking an item in the context menu was a problem because I think I need the wparam and lparam values of the message... and can't get those without attaching a watcher... which max doesn't-allow-imagine-that. So I send down arrow key presses and an enter key press instead. ha! take that! :( )

eek
12-11-2008, 04:49 AM
I got a problem,like this
- Create a box, then copy it so you have 2 box
- add an "edit poly" modifier and extrude some faces on first box.
- copy "edit poly" modifier from first box stack to second box

now you see the second box will have extrusions as well.

Is this possible with maxScript?

I have tried this:

mod=box01.modifiers[1]
addModifiers box02 mod

This will apply the modifier on the other box with the same settings but the extrusions are gone

any one can tell me how to do that with maxscript,thanks lot!!!

Im guessing at a hunch here but your instancing the modifier in the form of its creation with script rather than copying all of its history?

Does
local test = copy $.modifiers[#edit_mesh]

addModifiers $box02 test

work?

ZeBoxx2
12-11-2008, 05:11 AM
Does
local test = copy $.modifiers[#edit_mesh]

addModifiers $box02 test

work?

Nope, 'fraid not..

Try out the steps mentioned...
1. Create two boxes side-by-side
2. Apply an Edit Mesh or Edit Poly modifier to the left box
3. Go to the Poly sub-object level, and select one of the sides of the box
4. Bevel the selected face out
5. Exit the sub-object level (optional)
6. Right-click in the modifiers list, and choose Copy
7. Select the right box
8. Right-click in the modifiers list, and choose Paste
Upon pasting, you should see the same poly on the right box get beveled as well.

Now the only bit to worry about in the code is steps 6 and 8..


-- select the right box manually
deleteModifier $ 1 -- remove the modifier we had pasted manually
rBox = $

-- select the left box manually
lBox = $

-- get the modifier
theMod = lBox.modifiers[1]

-- try applying it to the right box in a number of ways:
-- standard modifier adding
addModifier rBox theMod
-- nope
deleteModifier $ 1
addModifier rBox (copy theMod)
-- nope
deleteModifier $ 1

-- through the modify panel
max modify mode
modPanel.addModToSelection theMod
-- nope
deleteModifier $ 1
modPanel.addModToSelection (copy theMod)
-- nope

-- maybe via replacing the instance (note that the modifier wasn't deleted last)
replaceInstances rBox.modifiers[1] theMod
-- nope
replaceInstances rBox.modifiers[1] (copy theMod)
-- nope

-- And that's where I ran out of fathomable options and tried the uiaccessor stuff


The only method I can think of, which is going to be pretty limited as well if there's multiple modifiers on the object to which you wish to paste the modifier, is to instance replace the object -below- the modifier.

e.g.

newObject = copy lBox
objectToGetTheModifiers = Sphere()
instanceReplace newObject objectToGetTheModifiers
delete objectToGetTheModifiers


But as all the modifiers that may pre-exist on objectToGetTheModifiers get lost, and you may not be able to re-apply them (due to the very problem we're trying to solve here), that's not always going to be a solution.

CGTalk Moderation
12-11-2008, 05:11 AM
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.