Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. ROMAN
    3. Posts
    • Profile
    • Following 0
    • Followers 0
    • Topics 11
    • Posts 26
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by ROMAN

    • RE: Selected object to selected layer

      I want to add selected objects at selected layer

      To my mind it should be in the following way:

      1. select object
      2. press the button of script
      3. select layer from the list of layers

      How to add all layers in custom menu If this variant is right?

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • Selected object to selected layer

      Hello for everyone! How to add selected objects at selected layer in layer mager?!!

      image.png

      @ferdinand

      edit: I restored your image, we will answer the posting tomorrow 🙂 [ferdinand]

      posted in Cinema 4D SDK python r25
      ROMANR
      ROMAN
    • RE: Layers checker

      @mogh I didn't know about this function 🤦
      @ferdinand Thank you a lot for your detailed response. I will chek posts which you recommended

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • Layers checker

      Hello guys! Is it real to check everything in layer (objects, materials, tags) and delete layer if its empty?

      posted in Cinema 4D SDK python s24 sdk
      ROMANR
      ROMAN
    • RE: How to Center the Axis of Objects

      @ferdinand

      Script add a null in center of world coordinates. I want to change it, i described what i want to do in pictures.

      1.jpg

      I added Mike's code, because i wanted to make 2 options for Step 2:

      • First option — script add axis poins of selected objects in center.
      • Second option — script add axis poins of selected objects in center but in the lowest position in Y coordinate. Mike's script could do this but just for one object. If i select objects more than one i get a message: "AttributeError: 'NoneType' object has no attribute 'GetAllPoints'".

      I'm sorry for my English...

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • How to Center the Axis of Objects

      @ferdinand , thank you a lot!
      When i tried to fix my code i used Mike Udin's example, but i couldn't understand why this code didn't work with multiple objects. I've got next message: "AttributeError: 'NoneType' object has no attribute 'GetAllPoints'".

      I supposed my script to set selected objects' axis points in the center for each other. After that the script should create a null between all axis points.

      import c4d
      
      def main():
          
          ps = op.GetAllPoints() #Points in Local coordinates List
          m = op.GetMg() #Object Global Matrix
      
          center = op.GetMp() #Local coordinates center: https://tinyurl.com/wed88cn
          rad = op.GetRad() # Geometry radius: https://tinyurl.com/tb6vn64
          
          center -= c4d.Vector(0,rad.y,0) #Move down axis to lowest point. Comment this line to keep axis in a center 
          
          center *= m #Convert to Global coordinates center
      
          new_m = c4d.Matrix(m) #Copy matrix
          new_m.off = center #Change its center
      
          loc_m = ~new_m * m #Get local matrix
      
          op.SetAllPoints([loc_m.Mul(p) for p in ps])
          op.SetMg(new_m)
          
          op.Message(c4d.MSG_UPDATE)
          c4d.EventAdd()
      
      
      if name == 'main':
          main()
      

      edit: This topic has been forked from How to fix the bug of objects position in script by @ferdinand

      posted in Cinema 4D SDK python r21
      ROMANR
      ROMAN
    • How to fix the bug of objects position in script

      Guys! Please, help. I cannot fix this problem.

      The main idea of ​​this script is:

      1. add selected objects and materials of these objects to the layer
      2. insert all objects under null.
        But position of objects changes. How to fix it?

      : video

      import c4d
      
      def main():
      
          doc.StartUndo()
      
      
          layer = c4d.documents.LayerObject()
          # Set layer name (another option tp set the name)
          # Get the invisible root layer
          layerRoot = doc.GetLayerObjectRoot()
          # Insert the layer under the parent
          layer.InsertUnder(layerRoot)
      
          name = layer.GetName()
          rvalue = c4d.gui.RenameDialog(name) # rename
          print(rvalue)
          layer [c4d.ID_BASELIST_NAME] = rvalue
          #layer.DelBit(c4d.BIT_ACTIVE)
      
          null_obj = c4d.BaseObject(c4d.Onull)
          null_obj [c4d.ID_LAYER_LINK] = layer
          null_obj [c4d.ID_BASELIST_NAME] = rvalue
          doc.InsertObject(null_obj)
      
      
          doc.AddUndo(c4d.UNDOTYPE_NEWOBJ, layer)
          doc.AddUndo(c4d.UNDOTYPE_NEWOBJ, null_obj)
      
          s = doc.GetSelection()
          vp = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_NONE)
      
      
          for obj in vp:
      
              print obj
      
              obj [c4d.ID_LAYER_LINK] = layer
              obj.InsertUnder(null_obj)
      
              obj_mat_tags = [t for t in obj.GetTags() if t.IsInstanceOf(c4d.Ttexture)]
      
              for tag in obj_mat_tags:
      
                  mat = tag.GetMaterial()
                  print mat
                  mat [c4d.ID_LAYER_LINK] = layer
      
      
          doc.EndUndo()
          c4d.EventAdd()
      
      if __name__ == '__main__':
          main()
      

      I use r21 version of c4d.

      posted in Cinema 4D SDK python r21
      ROMANR
      ROMAN
    • RE: Get port id of xpresso node

      @ferdinand Thank you a lot for your help! I'm really sorry for organization of my post. Could you point out on my mistakes in tagging?

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • Get port id of xpresso node

      Dear community!

      I want to create length port for spline node but I can’t find correct command for it.
      How to get id of port in form like this
      c4d.GV_PORT_OUTPUT, [c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_X]

      posted in Cinema 4D SDK python s24
      ROMANR
      ROMAN
    • RE: Insert scene under object

      Mike, thank you a lot!

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • RE: Xpresso set port for all nodes

      @m_magalhaes Thank you for answer!

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • Xpresso set port for all nodes

      Hello for everyone. Is it real to set up parameters like a position and rotation for all selected nodes by python?

      def main():
          nodes = [] 
          root = nodeMaster.GetRoot() 
          for node in root.GetChildren():
              if node.GetBit(c4d.BIT_ACTIVE): 
              ##place for setting parameter##
      

      If its real, could you write a command which set up x position in input for example

      posted in Cinema 4D SDK python
      ROMANR
      ROMAN
    • Insert scene under object

      Hello guys! I know how to merge a scene with a current project. But i have no idea how to insert scene under parent with coordinats of this parent.

      I want to create custom nulls thats why i want to it. What should i add in this code if i want insert scene under object?

      import c4d
      def main():
          doc.StartUndo() # Start recording undos
          path = "C:\Users\Jamaletdinov.r\Desktop\ArrowR.c4d" 
          flags = c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS | c4d.SCENEFILTER_MERGESCENE 
          c4d.documents.MergeDocument(doc, path, flags) 
          c4d.EventAdd()
          doc.EndUndo() 
      if __name__=='__main__':
          main()
      
      posted in Cinema 4D SDK python
      ROMANR
      ROMAN
    • RE: Set up selected user data value

      @ferdinand Sorry for the late reply. Yes you understood me correctly. Will this be fixed in new c4d versions?

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • Set up selected user data value

      Hello for every one. Does anybody know is it real to set up value for selected user data and for all user data in object? 2021-06-25_08-30-51.png

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • RE: Layer Selection Python

      @cairyn Thank you again. I will check your patreon

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • RE: Layer Selection Python

      @cairyn
      For example, we have 20 layers and i need to change visibility just for 2 layers in this list. That's what i meant when i talked about selected layers.

      I tried to use same code but it showed to me first layer in list....while i want to work with active layers which i have selected.

      And i wanted to ask which command delete layer?

      Sorry for stupid questions, but SDK a little bit unobvious.

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • RE: Layer Selection Python

      @cairyn, i don't understand just one thing how should i change a code if i want to do it with selected objects not for all.

      import c4d

      def visitLayer(layer):
      if layer == None: return
      print (layer.GetName())
      doc.AddUndo(c4d.UNDOTYPE_CHANGE, layer)
      layer [c4d.ID_LAYER_VIEW] = 1
      visitLayer(layer.GetDown())
      visitLayer(layer.GetNext())

      def main():
      doc.StartUndo()
      first = doc.GetLayerObjectRoot().GetDown()
      visitLayer (first)

      doc.EndUndo()
      c4d.EventAdd()
      

      if name=='main':
      main()

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • RE: Add user data to HUD by python

      It’s too bad, but thank you for your answer Manuel.

      posted in Cinema 4D SDK
      ROMANR
      ROMAN
    • Add user data to HUD by python

      Hello for everybody!

      I want to show all User Data of object in HUD. Is it real to make it by python,
      i checked SDK but didn't find something about User data HUD.

      Is it real or not?

      P.S. I found an information about viewport in general (visibility of polygons, joints and so on) but nothing about user data hud.

      posted in Cinema 4D SDK
      ROMANR
      ROMAN