Packed Automatic UVs Command in S22?



  • Hello, I'm struggling to figure out how to call the new Packed Automatic UV command from Python. I've found the BaseContainer where I can modify settings, but haven't figured out how to invoke the command.

    Alternatively being able to invoke the Set UVW From Projection... command with the automatic packed option would be even more straightforward in this case. Is that possible?



  • @wuzelwazel said in Packed Automatic UVs Command in S22?:

    Alternatively being able to invoke the Set UVW From Projection... command with the automatic packed option would be even more straightforward in this case. Is that possible?

    I should mention that I can use c4d.CallCommand(c4d.UV_SET_FROM_PROJECTION_CMD_ID) but in that case I don't know how to set the options for the command via Python.



  • Hi, I'm sorry I didn't get the time today to look more in detail, but you have CallUvCommand which accept one of the next flags (documentation is not yet correctly updated I will do next week):

    • c4d.UVCOMMAND_PACK_UV
    • c4d.UVCOMMAND_AUTOMATICUV
    • c4d.UVCOMMAND_PACK_RASTERIZED
    • c4d.UVCOMMAND_PACK_GEOMETRIC
    • c4d.UVCOMMAND_PACK_BOUNDINGBOX

    Next week I will provide examples about how to use them, in any case, you can find an example about CallUvCommand in the call_uv_command.py Example.

    Cheers,
    Maxime.



  • @m_adam Thanks Maxime!

    I'd found UVCOMMAND_AUTOMATICUV while perusing the depths of symbols.h yesterday but I couldn't find a way to make it work and I wasn't sure if it was what I needed... so I stopped looking into it. Your post renewed my enthusiasm and I went looking in the C++ SDK docs to find this:

    https://developers.maxon.net/docs/Cinema4DCPPSDK/html/group___m_d_a_t_a___a_u_t_o_m_a_t_i_c_u_v.html#gadd449518eb3bc7a84abe96673e62488a

    Which I believe will allow me to create my settings container for the command. I'll try this later today and let you know the results.

    It would be nice to have the python documentation updated too 👍



  • Well, it was a beautiful dream. The CallUVCommand to UVCOMMAND_AUTOMATICUV still fails when supplying a settings container based on the MDATA I found. In retrospect it does seem odd that these would be MDATA when the other UV command settings are not.

    Looking forward to your examples. I'll keep stabbing blindly in the dark in the meantime.



  • Hi @wuzelwazel this command being part of the new command, that is supposed to work without bodypaint it needs to be called via SendModelingCommand.
    Unfortunately for the moment, there is no symbols for this command ID.
    But here you are:

    import c4d
    
    # Main function
    def main():
        op = doc.GetActiveObject()
        settings = c4d.BaseContainer()
        settings[c4d.MDATA_AUTOMATICUV_TAGINDEX] = 0
        settings[c4d.MDATA_AUTOMATICUV_FORCESEAMS] = False
        settings[c4d.MDATA_AUTOMATICUV_OVERLAPMIRRORED] = False
        settings[c4d.MDATA_AUTOMATICUV_OVERLAPIDENTICAL] = False
        settings[c4d.MDATA_AUTOMATICUV_SPACING] = 0.01
        settings[c4d.MDATA_AUTOMATICUV_USENORMALS] = True
        settings[c4d.MDATA_AUTOMATICUV_SPACINGASPECT] = 1.0
        res = c4d.utils.SendModelingCommand(command=1053624,
                                    list=[op],
                                    mode=c4d.MODELINGCOMMANDMODE_POLYGONSELECTION,
                                    bc=settings,
                                    doc=doc)
        c4d.EventAdd()
    
    # Execute main()
    if __name__=='__main__':
        main()
    


  • I never would've found the command id so thanks a ton for sharing that. Marking as solved.


Log in to reply