Home Coding, Scripting, Shaders

reassigning materials in an fbx file with python

poopipe
grand marshal polycounter
Offline / Send Message
poopipe grand marshal polycounter
I've been struggling with this on and off for a few days now so I thought I'd ask here on the off chance. 

Using the python bindings for the autodesk fbx SDK  I want to take an object with multiple materials assigned and replace the assignments with a single material. 
I can remove materials from an object, I can create new materials and I can assign the new material to an object but I have completely failed to assign the new material to an object's faces.

Has anyone done anything like this ?  does anyone understand the system well enough to explain the architecture to an idiot? 


before anyone asks -  I can't do this within maya / whatever it needs to run as part of a larger process.


TIA :)

Replies

  • monster
    Offline / Send Message
    monster polycounter
    I haven't used the Python SDK. I just wanted to mention this is the type of task 3dsmaxbatch was made to perform. If I recall correctly, you can install 3ds Max and run 3dsmaxbatch without a license.

    Sorry I couldn't help more.
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    It's a good shout - I've considered it (albeit with maya's equivalent) but the time cost of just spinning it up is orders of magnitude greater than all the tasks my code already performs so the idea makes me a bit sad :(
  • monster
    Offline / Send Message
    monster polycounter
    Oh yeah, I had a request for 3dsmaxbatch a while back to open it and run it like a task server. That would be very handy to avoid repeated opening and closing of the software. I don't think that was ever developed though.

    Are your FBX's ASCII by chance? I've had success editing FBXs that were in ASCII format. Hopefully someone with FBX Python experience can answer you though.
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    They could be either binary or ascii - we tend to prefer binary for file size reasons but the sdk stuff works the same on both.  

    Its definitely doable - I just have to behave like a programmer rather than hack away at it like a tech artist :D
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    I've solved it. 

    I can't share the code cos work but ...
    You can pull a list of material indices by face ID from the layers on an individual fbx node's geometry, once you've got that you can edit the material indices to point at whatever material you want on a per face basis 

    turns out to be fairly straightforward as long as you're not dealing with instancing or other weirdness i haven't accounted for yet.



Sign In or Register to comment.