[Closed] Mergemaxfile problem
The user selects the file they want to merge in the object from.
Once the object is merged in, I want to select only that one object then position it
Problem is I am only able to select all of the objects. I am sure this is something easy, please help a noob out
[size=1]rollout HelmModifier “Parameters”
(
button obj_button “Select File” width:180
button file_button “Select Helm” width:180
global File
on obj_button pressed do
(
File = getOpenFileName caption:“Select file to open” types:“3d Max File (.max)|.max|All Files (.)|.|” –Get the helm setup file name from the user
names = getmaxfileobjectnames File –Get a list of all of the helms inside of the file
mergemaxfile File #prompt names #select –Brings up standard merge dialog box Then asks if you want to overwrite files
select objects –Select all of the objects in the scene
unhide selection –Unhide the helm loaded in
deselect selection
selection.position = [0,0,0] – Move the object into position
–getCurrentSelection (selection)
–file.count – returns number of objects in the scene should be 90
– objects.count – should be 9
)
)
try (closerolloutfloater HelmModifier_f)catch()
HelmModifier_f = newrolloutfloater “Helm Helper” 220 120
addrollout HelmModifier HelmModifier_F
[/size]
[/size]Since you already have the #select flag in the MergeMaxFile command, you should NOT call (select objects) or (deselect selection) as these will kill the selection that came from the merging. Instead, you can snapshot the selection into a variable, or just operate on it as you did in your script – (unhide selection) and (selection.pos = [0,0,0]) should affect only the (one or more) objects that were merged…
Thanks Bobo, though I still cannot get it to work properly. When it is prompted in it appears to ignore the #select command. To get around this I tried to assign the new file to a variable by saying name=mergemaxfile File #prompt then selecting the variable by name. . . no luck tho :0
Thank you again for your help, as well as any further advice you can give.
rollout HelmModifier “Parameters”
(
button obj_button “Select File” width:180
on obj_button pressed do
(
File = getOpenFileName caption:“Select file to open” types:“3d Max File (.max)|.max|All Files (.)|.|” –Get the helm setup file name from the user
name = mergemaxfile File #prompt –Brings up standard merge dialog box
select name–Select name variable
unhide name –Unhide the helm loaded in
name.position = [0,0,0] – Move the object into position
– deselect name
)
)
try (closerolloutfloater HelmModifier_f)catch()
HelmModifier_f = newrolloutfloater “Helm Helper” 220 120
addrollout HelmModifier HelmModifier_F
Oh, I missed the #prompt part.
Looks like #select does not work together with prompt.
There are two workarounds for this:
- Snapshot the current scene state, merge, then compare the new scene with the old to “fish out” the newly merged objects:
oldObjects = objects as array
mergeMaxFile File #prompt
newObjects = for o in objects where findItem oldObjects o == 0 collect o
- Write your own dialog to display the names of objects available in the selected file – as you know you can get the names using
names = getmaxfileobjectnames File
Then don’t use #prompt in the mergeMaxFile but pass the selected name(s) and use #select to just grab the new selection after the merge…
I would use 1. myself.