Jump to content

kalugin

Regular Member
  • Content Count

    296
  • Joined

  • Last visited

  • Days Won

    7

kalugin last won the day on October 20 2018

kalugin had the most liked content!

Community Reputation

68 Noble Beginner

Profile Information

  • First Name
    Alexander
  • Last Name
    Kalugin
  • C4D Ver
    16 Studio
  • Location
    Ruse, Bulgaria
  • Interests
    3D Visuals, Coding, CNC Machining, Off-grid living.

Recent Profile Visitors

3,028 profile views
  1. http://blog.grooff.eu/ has some interesting experiments also just searching "cinema4d python" in youtube returns some good results. And you can always ask here for help at some task :) Have fun.
  2. It's link is in the downloads section from quite some time, but i think that i've forgotten to make a topic here :D https://www.c4dcafe.com/ipb/files/file/1103-group-object/
  3. i don't think hiding polygons will optimize your workflow a lot. If it's the visual effect you are looking for, then OK. C4D can handle many polys with no problem. The issue comes with a lot of objects.
  4. import c4d from c4d import gui #Welcome to the world of Python def main(): camera = c4d.BaseObject(c4d.Ocamera) # this creates the object in the memory, but does not add it to the scene tag = c4d.BaseTag(c4d.Ttargetexpression) # this creates the tag in memory null = c4d.BaseObject(c4d.Onull) # create the null in memory doc.InsertObject(camera) # insert the camera object in the scene doc.InsertObject(null) # insert the null camera.InsertTag(tag) # apply the tag to the camera tag[c4d.TARGETEXPRESSIONTAG_LINK] = null # set the target object in the tag to be the null bd = doc.GetActiveBaseDraw() # get the active base draw object (This class represents a Cinema 4D window) currentCam = bd.GetEditorCamera() # get the "point" you are looking from camMatrix = currentCam.GetMg() # get the matrix of that point (position, rotation, scale) camera.SetMg(camMatrix) # apply that matrix to your newly created camera editor_size = bd.GetFrame() # gets the borders of the editor window in pixels x_center = editor['cr']/2 # 'cr' is the right border, divide by 2 and we get the x center y_center = editor['cb']/2 # 'cb' is the bottom border, divide by 2 and we get the y center center_point = bd.ProjectPointOnPlane(c4d.Vector(0, 0, 0), c4d.Vector(0, 1, 0), x_center, y_center)[0] # this function generates a 3D position on a virtual floor object, based on screen coordinates in x,y matrix = c4d.Matrix() # create an empty matrix matrix.off = center_point # set that matrix position to the center point null.SetMg(matrix) # set the null's matrix to the new matrix (with the center position) c4d.EventAdd() # inform cinema that something has happend, so it updates. if __name__=='__main__': main()
  5. null is created at 0,0,0. You didn't say that you want to create it somewhere else :)
  6. import c4d from c4d import gui #Welcome to the world of Python def main(): camera = c4d.BaseObject(c4d.Ocamera) # this creates the object in the memory, but does not add it to the scene tag = c4d.BaseTag(c4d.Ttargetexpression) # this creates the tag in memory null = c4d.BaseObject(c4d.Onull) # create the null in memory doc.InsertObject(camera) # insert the camera object in the scene doc.InsertObject(null) # insert the null camera.InsertTag(tag) # apply the tag to the camera tag[c4d.TARGETEXPRESSIONTAG_LINK] = null # set the target object in the tag to be the null bd = doc.GetActiveBaseDraw() # get the active base draw object (This class represents a Cinema 4D window) currentCam = bd.GetEditorCamera() # get the "point" you are looking from camMatrix = currentCam.GetMg() # get the matrix of that point (position, rotation, scale) camera.SetMg(camMatrix) # apply that matrix to your newly created camera c4d.EventAdd() # inform cinema that something has happend, so it updates. if __name__=='__main__': main()
  7. this is not really pythonic way to write a script :) Using callcommand will not get you very far in scripting. Try this. import c4d from c4d import gui #Welcome to the world of Python def main(): camera = c4d.BaseObject(c4d.Ocamera) # this creates the object in the memory, but does not add it to the scene tag = c4d.BaseTag(c4d.Ttargetexpression) # this creates the tag in memory null = c4d.BaseObject(c4d.Onull) # create the null in memory doc.InsertObject(camera) # insert the camera object in the scene doc.InsertObject(null) # insert the null camera.InsertTag(tag) # apply the tag to the camera tag[c4d.TARGETEXPRESSIONTAG_LINK] = null # set the target object in the tag to be the null c4d.EventAdd() # inform cinema that something has happend, so it updates. if __name__=='__main__': main()
  8. That's strange. It should work. Try with a .tiff file
  9. save the icon with the same name as the script and place it in the same folder as the script ;)
  10. Hahaha, no, it does not matter in which line you define the functions. :) But I would suggest using this as a script. Not in Xpresso, cause it will iterate every object in scene, every frame.
  11. this is the code in the node for everyone interested import c4d def main(): global result # sets a global output variable, cause the xpresso needs it :) result = state # sets the same output to the input state obj = doc.GetFirstObject() # this assigns the first object in the object manager to a variabale named "obj" while obj: # while there is an object returned if obj.GetType() == c4d.Osds: # if the object is a SDS object obj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = state # toggle it based on the null's object enabled's state obj = walker(obj) # keep checking all the objects in the scene. c4d.EventAdd() def walker(obj): if not obj: return elif obj.GetDown(): return obj.GetDown() while obj.GetUp() and not obj.GetNext(): obj = obj.GetUp() return obj.GetNext()
  12. well, if you are Ok with some Python - this a solution. But keep in mind that it will iterate over every object in the scene. It should be quite fast anyway :) sds xpresso python.c4d
  13. @Eterea you can ask anything man, just put it in different topic. I remember when py4d came out and there was no one to ask :) it was horrible
  14. The way I do it is not recommended :) But for monitoring only the ctrl alt shift, which is the most common case, it's quite easy to use.

YOUTUBE CHANNEL:

ABOUT US:

C4D Cafe is the largest CINEMA 4D community. We provide facilities for discussion, showcasing and learning our favorite software :)
×
×
  • Create New...