How to set project scale



  • Hi All,

    I'm trying to figure out how to change the Project scale and type (centimeters, meters etc etc) through python.

    I think I've to use the UnitScale class, but the documentation is a bit unclear about this class
    Reference:
    https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/CustomDataType/UnitScaleData/index.html#c4d.UnitScaleData

    Any help?


  • Global Moderator

    Hi Rage thanks for reaching us.

    With regard to your question, please consider that it was already discussed in the past in this thread.

    Long story short you can set the scene scale simply using

    def main():
        # check the current values for the currently active scene
        # for default scene it returns (1.0, 3) where scale is "1.0" and unit is "cm"
        print "current scale:", doc[c4d.DOCUMENT_DOCUNIT].GetUnitScale()
    
        # instantiate an UnitScaleData()
        sclData = c4d.UnitScaleData()
        # set the data accordingly to your needs
        # e.g. scale by 10x and set to mm units 
        sclData.SetUnitScale(10, c4d.DOCUMENT_UNIT_MM)
        # set the proper parameter in the active doc
        doc[c4d.DOCUMENT_DOCUNIT] = sclData
        # fire an EventAdd() 
        c4d.EventAdd()
    
        # check the new value
        print "new scale:", doc[c4d.DOCUMENT_DOCUNIT].GetUnitScale()
    

    Finally, to speed up your issues' resolution, I warmly encourage making use of the search function.

    Best, Riccardo