Select a single object from a file?
Posted: 24 April 2008 01:24 PM
Member
Avatar
Rank
Total Posts:  17
Joined  2006-08-22

I’m looking for a dialog that will prompt the user with the merge objects dialog, such as this:

mergeMAXFile "c:\\MyFile.max" #prompt

But, I want to restrict the user to selecting a single object, and I only want the object name in return.  (Don’t actually merge the object.) Is there a scriptable dialog that would let me do this?  I know that this dialog exists… for example if you make an Object-Xref, the Proxy Object option allows you to browse to a file and then select a single object in that file.  I suppose I could let it merge the object and then immediately delete it after getting it’s name, but that would be a wasteful solution if they want to pick a huge/complicated object.

Any ideas?

Thanks,
Ray

Ray Collett - Technical Director - Newlands & Company Inc.

 
 
 

Posted: 25 April 2008 09:17 AM   [ # 1 ]
Member
Avatar
Rank
Total Posts:  17
Joined  2006-08-22

Looks like this is another dialog not available to script.  I ended up designing my own dialog.

-Ray

Ray Collett - Technical Director - Newlands & Company Inc.

 
 
 

Posted: 25 April 2008 12:51 PM   [ # 2 ]
Platinum member
Avatar
RankRankRankRank
Total Posts:  155
Joined  2006-09-13

getMAXFileObjectNames <max_filename_string> [ quiet:<bool> ]

This command is listed a little further down the maxfile loading page in the MXS docs.

It gives you a list of objects in the file, but doesn’t do a merge.

 
 
 

Posted: 25 April 2008 02:59 PM   [ # 3 ]
Occupation: Technical Director VFX, Frantic Films
Administrator
Avatar
RankRankRankRank
Location: Winnipeg, Manitoba
Total Posts:  144
Joined  2006-08-24
ScriptChimp - 25 April 2008 12:51 PM

getMAXFileObjectNames <max_filename_string> [ quiet:<bool> ]

This command is listed a little further down the maxfile loading page in the MXS docs.

It gives you a list of objects in the file, but doesn’t do a merge.

That’s right, one can use this dialog to peek into the file and get the names of the objects that are inside.
Then, using this data, the mergeMaxFile() method could be called with one or more of these names to be merged.
Alternatively, the names could be displayed in a custom-made dialog containing a listbox or multilistbox to allow for selection.

There is a caveat though - if a user has saved the Max file with the option “Save File Properties” disabled in the Customize>Preferences>Files tab, the above method will fail and possibly even CRASH Max (at least it used to in Max 9) as it depends on reading the names of the objects from the Max file header which contains the stats of the scene and is uncompressed even if the Compress On Save is on.

Borislav “Bobo” Petrov

 
 
 

Posted: 25 April 2008 05:48 PM   [ # 4 ]
Member
Avatar
Rank
Total Posts:  17
Joined  2006-08-22
Borislav Petrov - 25 April 2008 02:59 PM

That’s right, one can use this dialog to peek into the file and get the names of the objects that are inside.
Then, using this data, the mergeMaxFile() method could be called with one or more of these names to be merged.
Alternatively, the names could be displayed in a custom-made dialog containing a listbox or multilistbox to allow for selection.

There is a caveat though - if a user has saved the Max file with the option “Save File Properties” disabled in the Customize>Preferences>Files tab, the above method will fail and possibly even CRASH Max (at least it used to in Max 9) as it depends on reading the names of the objects from the Max file header which contains the stats of the scene and is uncompressed even if the Compress On Save is on.

I ended up using the getMAXFileObjectNames() with a custom made object selector using listbox.  What I was looking for, was a command that presents the user with the standard max object selector interface (just like the mergeMAXFile() does), with the ability to restrict the user to selecting single objects, and returning the name of the object.

It’s good to know about the possibility for a failure/crash.  So far I have not seen that crash, but it probably would of been a lot of hours of headache trying to figure out the cause of such a crash.

-Ray

Ray Collett - Technical Director - Newlands & Company Inc.

 
 
 

Posted: 04 May 2008 11:41 PM   [ # 5 ]
Member
Rank
Total Posts:  3
Joined  2007-08-10

where did you get your avatar Ray?

-cpb

 
 
 

Posted: 11 May 2008 08:41 PM   [ # 6 ]
Member
Rank
Total Posts:  7
Joined  2008-04-23
Borislav Petrov - 25 April 2008 02:59 PM

ScriptChimp - 25 April 2008 12:51 PM


getMAXFileObjectNames <max_filename_string> [ quiet:<bool> ]

.... it depends on reading the names of the objects from the Max file header which contains the stats of the scene and is uncompressed even if the Compress On Save is on.

Bobo, your reply indicating the names of the objects are stored in the file header makes me wonder if there is a way to pull additional data about the objects out of the header through the IStorage interface (returned by Interface11::OpenMAXStorageFile)

I’d like to be able to filter the names of the objects returned by getMAXFileObjectNames based on whether or not the object is hidden, or in a specific layer --without having to merge the object in just to determine that I didn’t want it.

Any idea if this is worth exploring?

.biddle

 
 
 

Posted: 11 May 2008 11:14 PM   [ # 7 ]
Occupation: Technical Director VFX, Frantic Films
Administrator
Avatar
RankRankRankRank
Location: Winnipeg, Manitoba
Total Posts:  144
Joined  2006-08-24
Mike Biddlecombe - 11 May 2008 08:41 PM

Bobo, your reply indicating the names of the objects are stored in the file header makes me wonder if there is a way to pull additional data about the objects out of the header through the IStorage interface (returned by Interface11::OpenMAXStorageFile)

I’d like to be able to filter the names of the objects returned by getMAXFileObjectNames based on whether or not the object is hidden, or in a specific layer --without having to merge the object in just to determine that I didn’t want it.

Any idea if this is worth exploring?

In early days (around Max 4), this sort of object data was clearly visible inside the header even in a simple text editor. I used to access it using binary file input out of the Max file. Lately, it appears that the data might not be included in uncompressed form anymore - I suspect that Microsoft might have allowed Windows and 3rd party applications to include file properties in the ZIP stream, but I might be wrong. Using SDK interfaces or DotNet methods it might be accessible, so I think it is worth looking into it.
Let us know if you have any success…

Borislav “Bobo” Petrov

 
 
 

   
 
 

Forum theme Quick Jump
RSS 2.0 RSS 2.0 Atom Feed Atom Feed