Maya api: MFnSet::create

Started by
17 comments, last by RobTheBloke 15 years, 9 months ago
Heh, I've managed to find a couple of errors that were overlooked by changing to testing for success only, so thanks for that. Though still the same problems with the sets. I have no clue where I'm doing wrong with this.

Making Terralysia, wishlist now on Steam <3!

Advertisement
It's probably something else you are creating that's unable to be re-connected properly, and is then erroring during the load. That *could* make the set not re-appear since the file load bombs out before it gets to the objectSet. (at a guess)

I tried saving to ascii format and I couldn't find the set there. So it disappears already during the save process.

I guess it has something to do with how I create everything from within the writer method of the exporter. Or perhaps I'm forgetting something. I'll try and create a command plugin from your example and see if I can get it to work.

Making Terralysia, wishlist now on Steam <3!

There we go. I finally got it to work.

Apparently this was caused by creating and manipulating the set from within the writer function. If I execute the mel commands by using executeCommandOnIdle(), everything works just fine.

But this means that I have to use mel and the executeCommandOnIdle() function. Can this be done with the c++ api somehow? Without having to mess around with different threads and such?

Making Terralysia, wishlist now on Steam <3!

Quote:Original post by Flawe
Apparently this was caused by creating and manipulating the set from within the writer function.


Uhm.Why are you creating nodes in the writer function? That does kind of fly in the face of the purpose behind an exporter no? By any chance were you using MDgModifier to create that data?

Quote:Original post by Flawe
But this means that I have to use mel and the executeCommandOnIdle() function. Can this be done with the c++ api somehow? Without having to mess around with different threads and such?


Probably easiest to go with mel. Alternatively you can use an MMessage derived class to generate a C++ message. Possibly MSceneMessage::kAfterExport or something similar.
Quote:Original post by RobTheBloke
Uhm.Why are you creating nodes in the writer function? That does kind of fly in the face of the purpose behind an exporter no? By any chance were you using MDgModifier to create that data?


Um yeah, it sure does. The goal was to arrange the meshes into sets based on how they are exported. In case a scene would have a lot of different meshes that would be exported to different models.

I didn't use an MDGModifier, I used the exact code I posted above. You reckon it would have worked with a dg modifier instead?

That MSceneMessage looks interesting. It would probably produce much cleaner code.

Making Terralysia, wishlist now on Steam <3!

Quote:Original post by Flawe
Um yeah, it sure does. The goal was to arrange the meshes into sets based on how they are exported. In case a scene would have a lot of different meshes that would be exported to different models.


Once i was flown back from holiday about 2 days into a 2 week break because the pipeline needed to be modified inside of some game specific export code (and no one else knew how to use the Maya API). Putting that game specific stuff in a mel script and allowing it to be modifed would have prevented that.

More or less my entire export pipeline is configurable now and has a pretty fine grained level of control for just that reason. Are you sure you don't want to put that in a mel script :p

Quote:Original post by Flawe
I didn't use an MDGModifier, I used the exact code I posted above. You reckon it would have worked with a dg modifier instead?


Just wondering that's all. I've never actually tried creating data within a write method - it sounds like you'd be wondering into the land of the undefined however you did it tbh.

Quote:That MSceneMessage looks interesting. It would probably produce much cleaner code.


Maybe, though i get scared of those sorts of uses... and take care to clean it up properly - and take care that it doesn't get created if your export fails.

imo, arrangeMeshesIntoExportSets is a different operation to export.

my £0.02 ...
Thanks very much for all your help.

It does make sense to put stuff into mel script. I don't have much Maya coding experience but most of the problems I've had were caused by the api and were easily fixed with mel.

The only reason why I thought it would be a good idea to merge the set creation and exporting together was to make it more transparent for the artists. Not give them a few extra steps of creating and arranging the sets in their workflow.

Making Terralysia, wishlist now on Steam <3!

Quote:Original post by Flawe
The only reason why I thought it would be a good idea to merge the set creation and exporting together was to make it more transparent for the artists. Not give them a few extra steps of creating and arranging the sets in their workflow.


You can do that in other ways, for example it's pretty trivial to modify the export menu item callback to call your script, then the exporter. see this for starters....

This topic is closed to new replies.

Advertisement