Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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. Joel
    3. Posts
    J
    • Profile
    • Following 0
    • Followers 0
    • Topics 9
    • Posts 25
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by Joel

    • Create Splines without lines

      Hi,

      I am tasked with creating programmatically splines with no visible lines between the points.
      From the GUI I know I can create a spline with the Spline Pen or an already created spline and then delete the lines between the points using the Break Segment function. However, I don't know where to find any information on how to use the Break Segment from Python or any other option to achieve the same result of a spline without lines connecting the points.

      Any help is appreciated.

      Regards,
      Joel

      posted in Cinema 4D SDK python
      J
      Joel
    • RE: ExecutePasses to slow

      @ferdinand
      May I send you the project file and executable via a private channel?

      posted in Cinema 4D SDK
      J
      Joel
    • RE: ExecutePasses to slow

      @ferdinand
      Thank you for your reply.
      As of right now, I am executing all passes as I do not know for sure which passes I need.
      As I said I need the position and the base object color of sphere objects that follow a cloner. And this cloner has movements and colors set by inheritances.

      I have these spheres in a null so my code works in this manner (note I have two arrays for frames one for position and another for color as sometimes are different):

      null_spheres = doc.SearchObject('Spheres')
      
      spheres_names = []
      spheres_loc = []
      spheres_col = []
      
      frame_start = 0
      frame_end = 12000
      project_fps = 24
      
      for i in null_spheres.GetChildren():
        spheres_names.append(i.GetName())
        spheres_loc.append([])
        spheres_col.append([])
      
      frames_loc = list(range(frame_start, frame_end+1, project_fps))
      frames_col = list(range(frame_start, frame_end+1, project_fps))
      
      doc.SetTime(c4d.BaseTime(frame_start, project_fps))
      doc.ExecutePasses(None, True,  True, True, c4d.BUILDFLAGS_NONE)
      
      for frame_col in frames_col:
         t = c4d.BaseTime(frame_col, project_fps)
         doc.SetTime(t)
         doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_NONE)
         for index, sphere in enumerate(spheres_names):
            op = doc.SearchObject(sphere)
            col = op[c4d.ID_BASEOBJECT_COLOR]
            spheres_col[index].append([col.x, col.y, col.z])
            if frame_col in frames_loc:
               pos = op.GetMg().off
               spheres_loc[index].append([pos.x, pos.y, pos.z])
      

      As of right now, the number of spheres is around 200 but it will increase to 500 so I want to try and speed up this process as much as possible.

      posted in Cinema 4D SDK
      J
      Joel
    • ExecutePasses to slow

      Hi,

      I have a project where the Python scripts must gather information, like the position and color, of certain objects at all frames.
      As of right now, I am using SetTime and ExecutePasses. This action of SetTime ExecutePasses takes 0.13 seconds however my projects have 12000 frames therefore just the information gathering takes 26 minutes.
      Is there a way to speed up this prosses?

      Thank you for your time.
      Regards,
      Joel

      posted in Cinema 4D SDK python
      J
      Joel
    • RE: Dialog Menu

      Creating an instance for each subdialog solved the issue thank you so much.

      posted in Cinema 4D SDK
      J
      Joel
    • RE: Dialog Menu

      I tried using the subdialog as the github example shows. If I just want to do one subdialog change the github example that @mogh posted works just find. However when I add another button so I can switch between the subdialogs the Dialog does not update.

      The code I used is a bit modified from the github but more or less the same:

      import c4d
      from c4d import gui
      
      ID_SUBDIALOG = 10000
      ID_Dialog1_BUTTON = 10001
      ID_Dialog2_BUTTON = 10002
      
      class Dialog1(c4d.gui.SubDialog):
          def CreateLayout(self):
              self.AddStaticText(1, c4d.BFH_SCALEFIT, 0, 0, "Dialog 1")
              return True
      
      class Dialog2(c4d.gui.SubDialog):
          def CreateLayout(self):
              self.AddStaticText(1, c4d.BFH_SCALEFIT, 0, 0, "Dialog 2")
              return True
      
      class MainDialog(c4d.gui.GeDialog):
          subDialog = Dialog1()
          
          def CreateLayout(self):
              self.GroupBegin(0, c4d.BFH_SCALEFIT, 2)
              self.AddButton(ID_Dialog1_BUTTON, c4d.BFH_SCALEFIT, name="Dialog1")
              self.AddButton(ID_Dialog2_BUTTON, c4d.BFH_SCALEFIT, name="Dialog2")
              self.GroupEnd()
              
              self.AddSubDialog(ID_SUBDIALOG, c4d.BFH_SCALEFIT, 100, 100)
              self.AttachSubDialog(self.subDialog, ID_SUBDIALOG)
              
              return True
          
          def Command(self, mid, msg):
              if mid == ID_Dialog1_BUTTON:
                  self.subDialog = Dialog1()
                  self.AttachSubDialog(self.subDialog, ID_SUBDIALOG)
                  print(self.LayoutChanged(ID_SUBDIALOG))
              if mid == ID_Dialog2_BUTTON:
                  self.subDialog = Dialog2()
                  self.AttachSubDialog(self.subDialog, ID_SUBDIALOG)
                  print(self.LayoutChanged(ID_SUBDIALOG))
              return True
      
      if __name__=='__main__':
          dlg = MainDialog()
          dlg.Open(c4d.DLG_TYPE_ASYNC, defaultw=900, xpos=-2, ypos=-2)
      

      When I click the buttons the first button click from either button the LayoutChanged returns True but on the second button click from either button returns False.

      What am I doing wrong?

      posted in Cinema 4D SDK
      J
      Joel
    • Dialog Menu

      Hi,
      I have two dialogs in different python scripts and I would like to join them in a single python script so the user via buttons can choose what dialog to show.

      I tried searching the forums as well as reading the documentation but I have not been able to find a starting guide to solve this issue.

      Does anyone have an idea how I could achieve a solution to this problem?

      Thanks so much for your time.

      posted in Cinema 4D SDK python
      J
      Joel
    • RE: Inheritance created by Python script not getting saved

      @ferdinand Thank you so much. Adding:

      inheritance1.Message(c4d.MSG_MEUPREPARE, doc)
      

      Solved the issue.

      posted in Cinema 4D SDK
      J
      Joel
    • RE: Inheritance created by Python script not getting saved

      @ferdinand Thank you so much, looking forward to your reply.

      posted in Cinema 4D SDK
      J
      Joel
    • RE: Inheritance created by Python script not getting saved

      @ferdinand Is the information that I have provided sufficient?

      posted in Cinema 4D SDK
      J
      Joel
    • RE: Inheritance created by Python script not getting saved

      @ferdinand
      This is the part of the code corresponding to the set issue.Inheritance_error.c4d

      inheritance1 = c4d.BaseObject(1018775)
      inheritance1_Name = 'Inheritance-'+str(number)+ '_1'
      inheritance1.SetName(inheritance1_Name) # Set the first inheritance name.
      inheritance1.InsertUnder(null) # Insert the first inheritance under the null.
      inheritance1[c4d.MGINHERITANCEEFFECTOR_OBJECT] = cloner # Set the first inheritance Effector Object to the transition cloner.
      inheritance1[c4d.MGINHERITANCEEFFECTOR_MORPHMG] = True # Set the first inheritance Effector Morph Motion Object to True.
      inexcludedata1 = clonerbase[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST] # Get the cloner base Effectors List
      inexcludedata1.InsertObject(inheritance1, 1) # Insert the first inheritance in the Effectors List
      clonerbase[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST] = inexcludedata1 # Set the cloner base Effectors List.
      
      InheritanceID1 = find_DescID(clonerbase, inheritance1_Name)
      Inheritance1Track = c4d.CTrack(clonerbase, InheritanceID1) # Get the CTrack of the base cloner for the first inheritance.
      clonerbase.InsertTrackSorted(Inheritance1Track)
      Inheritance1Curve = Inheritance1Track.GetCurve() # Get the curve of the base cloner for the first inheritance.
      
      time = c4d.BaseTime(frames[0] - 1, doc.GetFps())
      clonerbase[InheritanceID1] = 0.0 # Set the strength of the first inheritance to 0.
      dictKey = Inheritance1Curve.AddKey(time)
      key = dictKey['key']
      Inheritance1Track.FillKey(doc, clonerbase, key) # Set the keyframe of the base cloner first inheritance strength.
      
      time = c4d.BaseTime(frames[0], doc.GetFps())
      clonerbase[InheritanceID1] = 1.0 # Set the strength of the first inheritance to 1.
      dictKey = Inheritance1Curve.AddKey(time)
      key = dictKey['key']
      Inheritance1Track.FillKey(doc, clonerbase, key)# Set the keyframe of the base cloner second inheritance strength.
      

      I have not shared all the code as this code is not meant to be public.

      I also have attached a Cinema 4D file where after the script run the inheritance works, but after a project save, close Cinema 4D reopen Cinema 4D, and the project, the inheritance does not work.

      Inheritance_error.c4d

      posted in Cinema 4D SDK
      J
      Joel
    • Inheritance created by Python script not getting saved

      Hi,
      I have a python script that creates inheritances with keyframes. All these work and get represented in the viewport, however when I save the project, close Cinema 4D, and then reopen the project, the inheritances are there with the keyframes, but their effects are not represented.

      And this only happens to the inheritances created by the script, manually created inheritances do work.

      What could be the issue?

      Thank you for your time.
      Joel.

      posted in Cinema 4D SDK python
      J
      Joel
    • RE: Get Spline Points Positions from PLA keyframes

      I am trying your code however I am getting ReferenceError: the object 'c4d.PointTag' is not alive.
      What could be the issue?

      posted in Cinema 4D SDK
      J
      Joel
    • Get Spline Points Positions from PLA keyframes

      Hi,

      I am tasked with obtaining the position of spline points from the PLA keyframes of the set spline.

      From the SDK, I ended up at a <c4d.PLAData object at 0x000001B118B7F2C0>
      But I do not know how to extract the spline points' positions from this PLAData object.

      Code to get the PLAData object:

      import c4d
      def get_PLAData():
           spline = doc.SearchObject('Spline')
           track = None
           PLA = c4d.DescID(c4d.DescLevel(c4d.CTpla, c4d.CTpla))
           tracks = spline.GetCTracks()
           
           for t in tracks:
               tid = t.GetDescriptionID()
               if tid[0] == PLA[0] : track = t
           
           curve = track.GetCurve()
           for i in range(curve.GetKeyCount()):
               key = curve.GetKey(i)
               data = key.GetGeData()
               print(data[c4d.CK_PLA_DATA])
      
      def main():
           get_PLAData()
      
      if __name__=='__main__':
           main()
           c4d.EventAdd()
      

      I also tried setting the document time with doc.SetTime(key.GetTime()) and then spline.GetAllPoints() but I am getting the same points' positions all the time.

      What am I doing wrong? Or how can I get the points' positions from the PLAData Object?

      Thank you for your time.

      posted in Cinema 4D SDK python
      J
      Joel
    • RE: Python Cloner Effectors Keyframe

      I was able to solve it by searching the DescID in the Cloner Description with the Inheritance Name.

      posted in Cinema 4D SDK
      J
      Joel
    • RE: Python Plugin GUI Tutorial

      Thank you so much for the information.
      If further information is needed I will reopen this question.

      posted in Cinema 4D SDK
      J
      Joel
    • RE: Trying to install Python package

      Thank you so much.
      All further communications will be done via email.

      posted in Cinema 4D SDK
      J
      Joel
    • Trying to install Python package

      Hi,

      I'm trying to install a python package. I've tried installing it with my python install and then moving the package folder inside the %APPDATA%/MAXON/{prefs}/python39/libs folder but when I try to import numpy I get: No module named 'numpy.core._multiarray_umath'
      Also as I read I have tried to install get-pip.py with the c4dpy but I get Error running authentication and it ask me to enter my Maxon Account login credentials, which gives me:
      Capture1.PNG
      As my Maxon Account login has to be done via my university login page.

      What should I do to solve this issue and install python packages?

      posted in Cinema 4D SDK
      J
      Joel
    • RE: Python Plugin GUI Tutorial

      Hi mogh,

      I was able to create a basic GUI with the github examples. But now I want to improve it. By improving it I mean that the user does not have to type the name of the object to select but rather that the GUI lets the user choose the object of the viewport.
      I don't really know how to do it but I found that a linkbox might be the solution however I am unable to find any examples of how to use it.

      Do you have any or do you know where I can find a tutorial on how to use the customgui?

      Joel.

      posted in Cinema 4D SDK
      J
      Joel
    • Python Plugin GUI Tutorial

      Hi,

      I am starting to finish my code in the script manager and I want to start coding the GUI for it to create a proper plugin.
      Where can I find a written or video tutorial on how to create a GUI with python?
      I have read the python SDK "tutorial" on GUI but it only talks about the layout files and does not give a starting example of how to create a GUI.

      Thank you so much for your time and help.

      Joel.

      posted in Cinema 4D SDK python
      J
      Joel