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. jenandesign
    3. Posts
    • Profile
    • Following 0
    • Followers 1
    • Topics 13
    • Posts 36
    • Best 2
    • Controversial 0
    • Groups 0

    Posts made by jenandesign

    • RE: using c4d.threading with (python) thinking particles

      Hello @ferdinand! I hope this message finds you and your team well.

      Sorry for the somewhat off-topic post, but I feel as though I must check back in after the last 2 weeks I have had.

      I dove right into Houdini particles for about 10 days and now have a loose understanding of the layout of the program- at least enough to use it for work. I continue to feel tugged to learn more, but just today I came across a person on youtube, Dominik Ruckli, who has been releasing some incredibly deep tutorials using scene nodes that make C4D look like Houdini- even building his own particle setup!

      After getting a lay-of-the-land in Houdini and now seeing the high level tool building potential in scene nodes, I can't help but think that C4D is actually not that far off from being able to match Houdini in a lot of ways.

      I hope that the new simulation based particle system you've mentioned is in-part integrated into scene nodes workflow, because the vast theory and knowledge of Houdini artists would be almost drag and drop back into C4D (as can be seen with Dominik's work on a few concepts/setups). So much potential.

      The future of C4D excites me so much now after what you have said. I hope you have a wonderful day!

      posted in General Talk
      jenandesignJ
      jenandesign
    • RE: using c4d.threading with (python) thinking particles

      @ferdinand said in using c4d.threading with (python) thinking particles:

      ...
      A new particle system based on the simulation framework is an item on our bucket list, but it might take some time until we get there.
      ...

      That makes me very happy to hear, thank you for that!

      X-Particles is very powerful and I have used it on many projects with great success over the years, but it misses the mark on UX within c4d due to the nature of it being third party. Working directly within and making use of all core toolsets in an integrated fashion is preferable when it comes to such delicate/intricate procedural tasks as particle motion. I have tried on several occasions to use X-Particles python API, but it as well suffers from severe performance restriction and a deluge of execution order mysteries- which always leads me back to just doing things in thinking particles. Simple.

      I am very happy to hear that c4d might someday have a new particle system, though. That is terribly exciting, because in the meantime I now must consider facing the houdini mountain yet again while I wait with hope 😰

      Thanks again for your response- you've definitely inspired hope in me to stick around. I really love C4D, and I think you are doing great work with all of the recent improvements!

      posted in General Talk
      jenandesignJ
      jenandesign
    • RE: using c4d.threading with (python) thinking particles

      Thank you so much for the clear response, @ferdinand !

      Oof... I have long been avoiding houdini, but I keep running into limits the deeper I go with particles in c4d python. Random things won't work in the TP python API (like trying to get/set a bool TP data channel among others), and the TP system as a whole feels like it hasn't been touched in a decade or maybe longer.

      Perhaps procedural particles (controlled with python/xpresso) in c4d are in need of a rebuff? I hope the dev team is talking about it or considers the importance, because at this point a move to houdini seems like the only viable option from a production standpoint as particle counts go up.

      I know this forum is mainly for plugin developers, and I appreciate you helping out anyway with this non-plugin-related topic. Thank you again

      posted in General Talk
      jenandesignJ
      jenandesign
    • using c4d.threading with (python) thinking particles

      Hello! I am curious if there are any gotchas to be aware of with using c4d.threading with thinking particles in Python.

      Specifically, if I have two particle groups (let's say groupA and groupB), will each thread performing calculations on groupA that depend on groupB and making changes to either of these groups be able to see the results recorded simultaneously as stored in the document as the threads run through their set of assigned particles to calculate?

      Let me break it down even further.

      Let's say I have 100k particles in groupA that I am going to break up into 10k chunks across 10 threads. At some point in the animation, each particle is instructed to find a match with a particle in groupB to act as a unique target (think of the particle in groupA acting as a homing missile trying to land on a particle in groupB). When the groupA particle gets matched with the groupB particle, a bool switch stored in a TP data channel (matched) is set on the groupB particle to remove it as a potential match for other groupA particles. This way, there are no groupA particle overlaps when all the particles have reached their targets.

      So essentially what I'm asking is... is this difficult to implement with threading? As each 10k particle count thread calculates, will they be able to see matches made via accessing groupB TP channel data from other threads as things are calculating? Will the TP channel data touched mid-process by one thread be seen by another thread? If not, is there some way to achieve this goal?

      posted in General Talk python
      jenandesignJ
      jenandesign
    • RE: Sampling a point in space from a userdata Field List

      ooh good catch! I would edit that comment if I could. thanks @ferdinand !

      pasting again w/ the fix:

      def FieldListSample(op, doc, positions, fields):
      
          cnt = len(positions)
          sampleFlags = c4d.FIELDSAMPLE_FLAG_VALUE | c4d.FIELDSAMPLE_FLAG_COLOR
      
          fieldInput = c4d.modules.mograph.FieldInput(positions, cnt)
          fieldInfo = c4d.modules.mograph.FieldInfo.Create(sampleFlags, None, doc, 0, 1, fieldInput, op)
          fieldOutput = c4d.modules.mograph.FieldOutput.Create(cnt, sampleFlags)
      
          fields.DirectInitSampling(fieldInfo)
          samplingSuccess = fields.DirectSample(fieldInput, fieldOutput.GetBlock(), fieldInfo)
          fields.DirectFreeSampling(fieldInfo)
      
          return fieldOutput
      
      
      # list of positions
      positions = [c4d.Vector(0, 0, 0)]
      
      # store the output (assumes that 'fields' is the FieldList)
      fieldOutput = FieldListSample(op, doc, positions, fields)
      
      # grab the weights as a list from fieldOutput
      weights = [fieldOutput._value[x] for x in range(fieldOutput.GetCount())]
      
      
      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign
    • RE: Sampling a point in space from a userdata Field List

      Extremely useful stuff if writing python generators / effectors or working with thinking particles in python.

      A feature request: adding some straight-to-the-point methods or a helper/abstraction class to streamline this in the future. Perhaps the dev team might even consider a few XPresso nodes for sampling Field Lists? Fields are so powerful and super exciting to use. Having a blast!

      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign
    • RE: Sampling a point in space from a userdata Field List

      my final working code(in a Python Tag, only mildly styled from mike's original):

      def FieldListSample(op, doc, positions, fields):
      
          cnt = len(positions)
          sampleFlags = c4d.FIELDSAMPLE_FLAG_VALUE | c4d.FIELDSAMPLE_FLAG_COLOR
      
          fieldInput = c4d.modules.mograph.FieldInput(positions, cnt)
          fieldInfo = c4d.modules.mograph.FieldInfo.Create(sampleFlags, None, doc, 0, 1, fieldInput, op)
          fieldOutput = c4d.modules.mograph.FieldOutput.Create(cnt, sampleFlags)
      
          fields.DirectInitSampling(fieldInfo)
          samplingSuccess = fields.DirectSample(fieldInput, fieldOutput.GetBlock(), fieldInfo)
          fields.DirectFreeSampling(fieldInfo)
      
          return fieldOutput
      
      
      # list of positions
      positions = [c4d.Vector(0, 0, 0)]
      
      # store the output (assumes that 'fields' is the FieldList)
      fieldOutput = def FieldListSample(op, doc, positions, fields)
      
      # grab the weights as a list from fieldOutput
      weights = [fieldOutput._value[x] for x in range(fieldOutput.GetCount())]
      
      

      cheers, thanks again to @mikeudin

      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign
    • RE: Sampling a point in space from a userdata Field List

      I found an example by @mikeudin that did the trick!

      Thanks so much for sharing!

      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign
    • Sampling a point in space from a userdata Field List

      Hello! It seems that it should be possible to sample a Field List from userdata in a Python Tag, however I am having a hard time getting going since there aren't many examples in existence.

      What I would really like to be able to do is this (sorry for the semi-psuedocode):

      # get the field list from userdata on the python tag
      fieldList = op[c4d.ID_USERDATA,1]
      
      # sample the field at a specific point in global 3D space
      weight = fieldList.Sample(c4d.Vector(0, 0, 0))
      

      I know the above code does not work, but maybe it is helpful describing what I'm after.

      Is this somehow possible in a Python Tag?

      posted in Cinema 4D SDK python
      jenandesignJ
      jenandesign
    • RE: add/remove/modify FieldList with python?

      Thanks so much, this points me in the right direction!

      Oof, I wish this was more easily accessible/abstracted like c4d.InExcludeData with insert/delete/get/count. Either way I appreciate the tip!


      edit 1: Ok, I see that I can just create a new field list and replace the object's data with it, this works.

      import c4d
      
      doc: c4d.documents.BaseDocument
      op: c4d.BaseTag
      
      def main() -> None:
          deformer = op[c4d.ID_USERDATA,1]
          splineGroup = op[c4d.ID_USERDATA,2]
      
          fieldList = c4d.FieldList()
          deformer[c4d.FIELDS] = fieldList
          c4d.EventAdd()
          pass
      

      I have a null object splineGroup containing several c4d.SplineObject that I would like to add as spline field layers to the FieldList stack


      edit 2: Digging through, but I don't see how it is possible to add a Spline Field Layer with python.


      edit 3: I figured it out 🙂

      import c4d
      
      doc: c4d.documents.BaseDocument
      op: c4d.BaseTag
      
      def main() -> None:
          deformer = op[c4d.ID_USERDATA,1]
          splineGroup = op[c4d.ID_USERDATA,2]
          splines = splineGroup.GetChildren()
      
          fieldList = c4d.FieldList()
      
          for spline in splines:
              fieldLayer = c4d.modules.mograph.FieldLayer(c4d.FLspline)
              fieldLayer.SetLinkedObject(spline)
              fieldList.InsertLayer(fieldLayer)
      
          deformer[c4d.FIELDS] = fieldList
          c4d.EventAdd()
          pass
      

      edit 4: Ok, it appears that the script above does not work for multiple splines/layers


      edit 5: I know this is probably a simple solve, but it's eluding me.

      If I break out the for loop with unique variable names, I can have multiple FieldLayers populating the FieldList.

      However, running in a for loop as shown above, I only get one... The last spline in the for loop which is definitely a clue.

      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign
    • add/remove/modify FieldList with python?

      Hello, I am having trouble making changes via python to a FieldList existing on a deformer. Ultimately, I will need to flush and procedurally rebuild a FieldList if possible.

      As a first test of the API, I tried c4d.FieldList.Flush() and this does not seem to stick- existing FieldLayers remain. Also, I don't see any options to access specific layer?

      I feel like I am missing something obvious- any help is appreciated 🙂

      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign
    • Python Effector as Deformer w/ Fields shows in viewport but does not render

      As soon as I add a field to a Python Effector with deform mode enabled, the poly object will no longer be affected by the deform when rendered. However, it renders in the viewport just fine?

      Am I missing something obvious?

      Thanks for the help!

      c4d version 2023.2.1

      rnd_PyEffDeformerWithField_NotShownInRender.c4d


      edited by @ferdinand:

      Code:

      import c4d
      
      op: c4d.BaseObject # The python effector
      gen: c4d.BaseObject # The MoGraph Generator executing the effector
      doc: c4d.documents.BaseDocument # The document evaluating this effector
      thread: c4d.threading.BaseThread # The thread executing this effector
      
      def main() -> bool:
          # Called when the effector is executed to set MoGraph data. Similar to EffectorData::ModifyObject in C++.
          moData = c4d.modules.mograph.GeGetMoData(op)
          if moData is None:
              return False
      
          cnt = moData.GetCount()
          marr = moData.GetArray(c4d.MODATA_MATRIX)
      
          hasField = op[c4d.FIELDS].HasContent()
          fall = moData.GetFalloffs()
      
          for i in range(0, cnt) :
              if hasField:
                  if i%4 == 0:
                      marr[i].off = marr[i].off + fall[i] * 1.0
              else:
                  if i%4 == 0:
                      marr[i].off = marr[i].off + 1.0
      
          moData.SetArray(c4d.MODATA_MATRIX, marr, hasField)
          return True
      

      @jenandesign said:

      uh oh, maybe this still hasn't been fixed?

      Feb 2020: https://developers.maxon.net/forum/topic/12325/python-effector-full-control-has-no-effect-during-render

      Nov 2020: https://developers.maxon.net/forum/topic/13006/python-effector-not-working-with-fields

      The workaround described in another report about this is to use the MoGraph Cache object. Sadly, that only works for MoGraph objects and not deformed polygon objects. Hopefully, a fix is around the corner crosses fingers

      posted in Bugs python 2023 sdk
      jenandesignJ
      jenandesign
    • RE: USDA support for Redshift Materials?

      Thanks for the response @i_mazlov !

      That's what I figured, based on what the RS team told me. I am definitely wondering about RS native materials 😄

      posted in General Talk
      jenandesignJ
      jenandesign
    • USDA support for Redshift Materials?

      Hello, I was wondering if anyone is working on USDA import support for Redshift Materials?

      Someone on RS team suggested to me over discord that I write the thing myself (presumably with C4D python), but USDA import of RS materials seems like something that will officially be supported in only a matter-of-time.

      Though it kind of sounds like fun in that it would be helpful to many people, I don't want to start on it if it's already being worked on officially?

      Any info is greatly appreciated. Thanks so much!

      Leah

      posted in General Talk
      jenandesignJ
      jenandesign
    • RE: baking material channel and applying result to another material from python tag

      Hello @ferdinand. I realized there is no need to create a new shader in the material, simply updating/maintaining the Xbitmap file path should suffice.

      Thankfully tempfile is giving me no issues with the farm.

      However the problem I am having now is that the material does not update with the texture as it changes. I tried everything from BaseMaterial.GetPreview() to BaseMaterial.Message(c4d.MSG_UPDATE) to BaseMaterial.Update() at no avail. If you have any recommendations how I can force a reload of the Xbitmap's file, I am all ears.

      import c4d
      import tempfile
      import os
      #Welcome to the world of Python
      
      def main():
          baking = op[c4d.ID_USERDATA,4] # a boolean flag
          if baking == True:
              return
      
          # Set some variables
          texTags = [op[c4d.ID_USERDATA,1]]    # source texture tag
          texUVWs = [op[c4d.ID_USERDATA,2]]
          destUVWs = [op[c4d.ID_USERDATA,3]]
          destMat = op[c4d.ID_USERDATA,5]      # destination material
      
          # Bake texture setup
          bc = c4d.BaseContainer()
          bc[c4d.BAKE_TEX_SURFACECOLOR] = True
          bc[c4d.BAKE_TEX_PIXELBORDER] = 3
          bc[c4d.BAKE_TEX_WIDTH] = 1024
          bc[c4d.BAKE_TEX_HEIGHT] = 1024
      
          # Init bake texture, prevent recursion
          op[c4d.ID_USERDATA,4] = baking = True
          bakeInfo = c4d.utils.InitBakeTexture(doc, texTags, texUVWs, destUVWs, bc, None)
          op[c4d.ID_USERDATA,4] = baking = False
      
          # Create new bitmap and bake texture
          newBitmap = c4d.bitmaps.MultipassBitmap(1024, 1024, c4d.COLORMODE_RGBw)
          bakeTextureInfo = c4d.utils.BakeTexture(bakeInfo[0], bc, newBitmap, None, None)
      
          # Store bitmap to file
          tempFilePath = os.path.join(tempfile.gettempdir(), "tempBitmap.png")
          newBitmap.Save(tempFilePath, c4d.FILTER_PNG)
      
          # Update the destination material
          shader = destMat[c4d.MATERIAL_LUMINANCE_SHADER]
          shader[c4d.BITMAPSHADER_FILENAME] = tempFilePath
          # Nothing seems to be working after this to update the material
          destMat.GetPreview()
          destMat.Message(c4d.MSG_UPDATE)
          destMat.Update(True, True)
          c4d.EventAdd()
      
          return None
      
      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign
    • RE: baking material channel and applying result to another material from python tag

      Hi @ferdinand- thanks again for the guidance. Do you have any suggestions about how to avoid the issues you've pointed out?

      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign
    • RE: baking material channel and applying result to another material from python tag

      One thing I still have yet to figure out is how to get the destination material to update its texture in the viewport/editor.

      How to run c4d.BITMAPSHADER_RELOADIMAGE?

      https://developers.maxon.net/docs/py/2023_2/classic_resource/shader/xbitmap.html

      Thank you,
      Leah

      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign
    • RE: baking material channel and applying result to another material from python tag

      Hello @ferdinand! Thank you for your incredibly well thought out and detailed response! I really appreciate it. The amount of information you have come back with from my hodgepodge posting is illuminating to say the least.

      • Why does it have to be a Python Programming Tag? Why not just some Script Manger script with GeDialog for example? Which would lend itself much better for this.

      The reason for a Python Tag is threefold:

      • My task requires that the operation updates on every frame so that other systems can be built upon it. This rules out a Script Manager script which would need to be executed manually and does not work at render time. Specifically in my case, I am trying to achieve particle emission via texture luminance that is baked from lights / surface color.
      • The setup is to be shared across a team of remote workers, and requiring other team members to manage/update a plugin or script file along with a scene file adds undue complexity to an otherwise simple tool. It is much easier to have every bit of kit live in the scene file alone.
      • As mentioned earlier, this will be rendered on a farm [remotely], and this is another reason to keep everything contained within the scene file (as opposed to a plugin which would require the farm admin to manage installations and updates).

      At the recommendation of a very smart and dear friend, I am using a bit of user data to store a baking state/flag. With this, I was able to hack my way through the recursion issue. Things are now working as intended.

      import c4d
      import tempfile
      import os
      #Welcome to the world of Python
      
      def main():
          baking = op[c4d.ID_USERDATA,4] # a boolean flag
          if baking == True:
              return
      
          # Set some variables
          texTags = [op[c4d.ID_USERDATA,1]]    # source texture tag 
          texUVWs = [op[c4d.ID_USERDATA,2]]
          destUVWs = [op[c4d.ID_USERDATA,3]]
          destMat = op[c4d.ID_USERDATA,5]      # destination material
      
          # Bake texture setup
          bc = c4d.BaseContainer()
          bc[c4d.BAKE_TEX_SURFACECOLOR] = True
          bc[c4d.BAKE_TEX_PIXELBORDER] = 3
          bc[c4d.BAKE_TEX_WIDTH] = 1024
          bc[c4d.BAKE_TEX_HEIGHT] = 1024
      
          # Init bake texture, prevent recursion
          op[c4d.ID_USERDATA,4] = baking = True
          bakeInfo = c4d.utils.InitBakeTexture(doc, texTags, texUVWs, destUVWs, bc, None)
          op[c4d.ID_USERDATA,4] = baking = False
      
          # Create new bitmap and bake texture
          newBitmap = c4d.bitmaps.MultipassBitmap(1024, 1024, c4d.COLORMODE_RGBw)
          bakeTextureInfo = c4d.utils.BakeTexture(bakeInfo[0], bc, newBitmap, None, None)
      
          # Store bitmap to file
          tempFilePath = os.path.join(tempfile.gettempdir(), "tempBitmap.png")
          newBitmap.Save(tempFilePath, c4d.FILTER_PNG)
      
          # Update the destination material
          shader = c4d.BaseList2D(c4d.Xbitmap)
          shader[c4d.BITMAPSHADER_FILENAME] = tempFilePath
          destMat.InsertShader(shader)
          destMat[c4d.MATERIAL_LUMINANCE_SHADER] = shader
          destMat.Message(c4d.MSG_UPDATE)
          destMat.Update(True, True)
          c4d.EventAdd()
      
          return None
      
      if __name__=='__main__':
          main()
      
      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign
    • baking material channel and applying result to another material from python tag

      Hello, perhaps it is pretty self explanatory from the title what I am seeking to do.

      I am avoiding making a plugin at all costs due to the added complexity (both from a developmental standpoint as well as having to ask IT to install a plugin across a massive farm for a single job).

      So, I am trying to do everything from a Python Tag which I know carries caveats in terms of what is possible. But in a nutshell, I am trying to render a material channel on one object and then apply the result in an xbitmap shader in another material.

      So far I have tried a few things, but with no success because I can't find examples of other people doing this so far.

      I have tried:

      • creating a bake texture tag and using CallButton on the bake button, using a frame checker to make sure it runs only once when the frame is changed. This should work, but then the file that is generated and written to disk tries to overwrite itself which displays a dialog asking "Yes or No" and I have yet to figure out how to "click" one of these buttons to get through this dialog.
      • creating a new bitmap and using c4d.utils.BakeTexture, but I am running into issues getting this set up as there are no examples running it from a Python Tag (nor do I know if it's even feasible)

      Thanks for any and all help / recommendations!

      Follow up postings (edited by @ferdinand):

      Hello again, checking back in. I have made some progress using an example I found:
      https://developers.maxon.net/forum/topic/461

      My code so far is as follows:

      import c4d
      import tempfile
      import os
      #Welcome to the world of Python
      
      def main():
      
          # Set some variables
          obj = op.GetObject()
          texTags = [obj.GetTag(c4d.Ttexture)]
          texUVWs = [obj.GetTag(c4d.Tuvw)]
          destUVWs = [obj.GetTag(c4d.Tuvw)]
      
          # Bake texture setup
          bc = c4d.BaseContainer()
          bc[c4d.BAKE_TEX_WIDTH] = 512
          bc[c4d.BAKE_TEX_HEIGHT] = 512
          bc[c4d.BAKE_TEX_CONTINUE_UV] = False
          bc[c4d.BAKE_TEX_SUPERSAMPLING] = 0
          bc[c4d.BAKE_TEX_FILL_COLOR] = c4d.Vector(1)
          bc[c4d.BAKE_TEX_USE_BUMP] = False
          bc[c4d.BAKE_TEX_USE_CAMERA_VECTOR] = False
          bc[c4d.BAKE_TEX_AUTO_SIZE] = False
          bc[c4d.BAKE_TEX_NO_GI] = False
          bc[c4d.BAKE_TEX_GENERATE_UNDO] = False
          bc[c4d.BAKE_TEX_PREVIEW] = False
          bc[c4d.BAKE_TEX_SURFACECOLOR] = True
          bc[c4d.BAKE_TEX_UV_LEFT] = 0.0
          bc[c4d.BAKE_TEX_UV_RIGHT] = 1.0
          bc[c4d.BAKE_TEX_UV_TOP] = 0.0
          bc[c4d.BAKE_TEX_UV_BOTTOM] = 1.0
          bc[c4d.BAKE_TEX_NORMAL_METHOD] = c4d.BAKE_TEX_NORMAL_METHOD_OBJECT
      
          # Initialize bake texture
          bakeInfo = c4d.utils.InitBakeTexture(doc, texTags, texUVWs, destUVWs, bc, None)
      
          # Create new bitmap and bake texture
          newBitmap = c4d.bitmaps.MultipassBitmap(512, 512, c4d.COLORMODE_RGB)
          bakeTextureInfo = c4d.utils.BakeTexture(bakeInfo[0], bc, newBitmap, None, None)
      
          # Store bitmap to file
          tempFilePath = os.path.join(tempfile.gettempdir(), "tempBitmap.png")
          newBitmap.Save(tempFilePath, c4d.FILTER_PNG)
          print(tempFilePath)
      
          return None
      
      if __name__=='__main__':
          main()
      

      However I am getting crashes immediately after running the InitBakeTexture command. Any idea what I'm doing wrong?

      Also for some reason the tag script will run over 300 times upon file save even if the tag is disabled when InitBakeTexture exists in the script. Assuming this has something to do with thread = None and running on the main thread?

      R25.010

      I tried print(texTags, texUVWs) in the Set some variables section and then got the following error after doing 334 logs for the above issue:

      RecursionError: maximum recursion depth exceeded while getting the repr of an object

      Seems like when I do InitBakeTexture and save the file, it's opening another thread recursively and running the script again. Not sure why this is happening, but I'm pretty sure this is why I am getting crashes when I actually enable the tag.

      EDIT: looks like InitBakeTexture is causing a stack overflow, but I have no idea why.

      EDIT2: just realized it's creating a new doc. Ah ha

      EDIT3: okay not sure if it's a new doc or what, but it's definitely looking like a stack overflow. Any ideas why this is happening?

      Simplified test code (applied to Python Tag):

      import c4d
      #Welcome to the world of Python

      def main():
      
          # Set some variables
          obj = op.GetObject()
          texTags = [obj.GetTag(c4d.Ttexture)]
          texUVWs = [obj.GetTag(c4d.Tuvw)]
          destUVWs = [obj.GetTag(c4d.Tuvw)]
      
          print(texTags, texUVWs)
      
          # Bake texture setup
          bc = c4d.BaseContainer()
          bc[c4d.BAKE_TEX_COLOR] = True
          bc[c4d.BAKE_TEX_COLOR_ILLUM] = True
          bc[c4d.BAKE_TEX_NO_INIT_BITMAP] = True
          bc[c4d.BAKE_TEX_WIDTH] = 512
          bc[c4d.BAKE_TEX_HEIGHT] = 512
      
          bakeInfo = c4d.utils.InitBakeTexture(doc, texTags, texUVWs, destUVWs, bc, None)
      
          return None
      
      if __name__=='__main__':
          main()
      I believe InitBakeTexture causing a stack overflow
      

      I should mention this only happens when making a change to the Python Tag script and then saving the file.

      posted in Cinema 4D SDK python r25
      jenandesignJ
      jenandesign
    • Generating a usable spline with a Python Generator

      This topic has been broached before over the years, but I think it should be mentioned again.

      There is no easy way to make a spline generated with a python generator that is usable in other parts of the program due to the internal hierarchy within c4d python and caching / generating "contours" as noted with the Python Generator object etc.

      The only solution available to generate procedural splines (usable in other generator objects) is that users are expected to make full ObjectData plugins.. which is unnecessarily time consuming, and places a much larger mountain to climb in front of new users of c4d python. I think this feature would be incredibly powerful and time saving if it was easier, even as someone who knows how to write ObjectData plugins.

      I hope you will please consider adding this functionality to return usable splines in the Python Generator in a future release or update to c4d python. Thanks for your consideration!

      posted in Cinema 4D SDK
      jenandesignJ
      jenandesign