PDA

View Full Version : Mergemaxfile problem


Jonbojangles
02-08-2006, 12:56 AM
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 :)

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

Bobo
02-08-2006, 03:35 AM
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 :)




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...

Jonbojangles
02-08-2006, 05:48 PM
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

Bobo
02-08-2006, 08:36 PM
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.


Oh, I missed the #prompt part.
Looks like #select does not work together with prompt.

There are two workarounds for this:

1. 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

2. 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.

Jonbojangles
02-09-2006, 01:13 AM
This Works Perfectly now.

Thank you so much.

--Jon

CGTalk Moderation
02-09-2006, 01:13 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.