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. james.thamesview
    J
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 4
    • Best 0
    • Controversial 0
    • Groups 0

    james.thamesview

    @james.thamesview

    0
    Reputation
    5
    Profile views
    4
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    james.thamesview Unfollow Follow

    Latest posts made by james.thamesview

    • RE: Python generator

      @i_mazlov
      Thanks for your help. I using visual studio code as you suggested and am getting to grips with the Drag and Drop to assist with parameter getting and setting.

      posted in Cinema 4D SDK
      J
      james.thamesview
    • Python generator

      I am using a python generator to produce sets of splines. I want the code to check the python generator object for a hair tag. Then I want to get the underlying hair material colour gradient and use that as the basis for customer hair textures to be applied to the splines
      this is a snippet of what I have so far (mainly using copilot to help me)
      for tag in op.GetTags():

              #print (tag,tag.GetType())
                  if tag.GetType() == c4d.Thairmaterial:
                      material_tag = tag
                      material = material_tag.GetMaterial()
                      source_gradient = material[c4d.HAIR_MATERIAL_COLOR_GRADIENT]
                      gradient = hair_material[c4d.HAIR_MATERIAL_COLOR_GRADIENT]
                      for i in range(gradient.GetKnotCount()):
                          knot = gradient.GetKnot(i)
                          print(f"Knot {i}: Color = {knot.col}, Position = {knot.pos}")     
              
              break
      

      This fails with "AttributeError: 'c4d.BaseTag' object has no attribute 'GetMaterial' "
      It looks to me like python is not seeing tag as a Hair material and/or I am calling the wrong method to get the underlying material.
      So two questions:
      1: how do I correct this
      2: what should I be searching for in the docs to be able to work this out for myself

      Thanks in advance

      Regards

      Jim

      posted in Cinema 4D SDK 2025 python
      J
      james.thamesview
    • RE: Python reading fields issue

      Thanks for looking at this. Does this main that it is at least on the "to do" list again?
      Does it still work in c++

      posted in Bugs
      J
      james.thamesview
    • Python reading fields issue

      Dear community,

      is it possible that the method c4d.modules.mograph.FieldInfo.Create() is (currently) bugged ie from 2024 onwards?

      As an example:
      I took this script from

      , (and simplified it a little)

      import c4d
      from c4d.modules.mograph import FieldInput, FieldInfo, FieldOutput
      
      def fieldlist_sampling(op, doc, poslist, fields):
      
          pCount = len(poslist)
          sample_flags = c4d.FIELDSAMPLE_FLAG_VALUE | c4d.FIELDSAMPLE_FLAG_COLOR
      
          fieldInput = FieldInput(poslist, allocatedCount=pCount)
          fieldInfo = FieldInfo.Create(sample_flags, None, doc, 0, 1, fieldInput, op)
          fieldOutput = FieldOutput.Create(pCount, sample_flags)
      
          fields.DirectInitSampling(fieldInfo)
          samplingSuccess = fields.DirectSample(fieldInput, fieldOutput.GetBlock(), fieldInfo)
          fields.DirectFreeSampling(fieldInfo)
      
          return fieldOutput
      
      
      
      def main():
      
          count =5                                        
          distance = 225    
          fields = op[c4d.ID_USERDATA,1]
      
          null = c4d.BaseObject(c4d.Onull)
      
          if not count:
              return null
      
          div = ((count-1)/2)*distance
          poslist = [c4d.Vector((distance*c)-div,0,0) for c in range(0,count)]
          samp_list = fieldlist_sampling(op, doc, poslist, fields)
          # samp_list._value
      
      
          for n,p in enumerate(poslist):
              cube = c4d.BaseObject(c4d.Ocube)
              cube.SetRelPos(p)
              value = c4d.utils.RangeMap(value=samp_list._value[n], mininput=0, maxinput=1, minoutput=20, maxoutput=150, clampval=False)
              cube[c4d.PRIM_CUBE_LEN] = c4d.Vector(value)
              cube[c4d.ID_BASEOBJECT_USECOLOR] = 2
              cube[c4d.ID_BASEOBJECT_COLOR] = samp_list._color[n]
      
              cube.InsertUnder(null)
      
          return null
      

      It is for a python generator with a field list in user data (id=1), field list contains a linear field.
      When the field is moved the cubes change size and colour, the script is not perfect, it's just to demonstrate.

      The generator works on 2023 and below but not in 2024 and above
      This it the running in 2023:
      c8c14a1b-df65-4797-b476-b6d6edfae79c-image.png

      and this is 2025af56c5c5-ed96-4c41-894b-826b4e1415ee-image.png

      posted in Bugs python 2023 2024
      J
      james.thamesview