SAFINA3D

C4D script : Basic Test Scene

Hi,
this is my first script that I made in order to create a simple scene quickly for render tests
(floor + sphere + light)
code source (python) :

import c4d
from c4d import documents

def main():

    scene = documents.GetActiveDocument()
    #------------------------------------------------------------------
    c4d.CallCommand(5160) # sphere
    c4d.CallCommand(5104) # sol
    c4d.CallCommand(5102) # omni
    #------------------------------------------------------------------
    objL = scene.SearchObject("Light")
    objL.SetAbsPos(c4d.Vector(-400,400,-400))
    objL[c4d.LIGHT_SHADOWTYPE] = 1
    objC = scene.SearchObject("Sphere")
    objC[c4d.PRIM_SPHERE_RAD] = 50 # radius
    objC[c4d.PRIM_SPHERE_SUB] = 36 # segments
    objC.SetAbsPos(c4d.Vector(0,50,0))
  

    objSol = scene.SearchObject("Floor")

    matSphere = c4d.BaseMaterial(c4d.Mmaterial) #Mat Sphere
    matSol = c4d.BaseMaterial(c4d.Mmaterial) #Mat Sol

    matSphere.SetName("mSphere")
    matSol.SetName("mSol")
    matSphere[c4d.MATERIAL_COLOR_COLOR] = c4d.Vector(0.925, 0.3, 0.053)
    matSol[c4d.MATERIAL_COLOR_COLOR] = c4d.Vector(0.247, 0.247, 0.247)
    scene.InsertMaterial(matSphere)
    scene.InsertMaterial(matSol)

    scene.SetActiveObject(objC)
    scene.SetActiveMaterial(matSphere)
    c4d.CallCommand(12169)

    scene.SetActiveObject(objSol)
    scene.SetActiveMaterial(matSol)
    c4d.CallCommand(12169)



if __name__ == "__main__":
    main()

2 comments

  1. 44 string wrong

    must like this^
    if __name__=='__main__':

    ReplyDelete
  2. I forgot to move main() to the right at the end of the script.
    indentation can cause problems in python
    Thank you :), I corrected it now

    ReplyDelete