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

    issue with inserting fieldlayers in r2024

    Bugs
    windows python 2024
    3
    4
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      datamilch
      last edited by

      hi there,

      I'm having a weird issue with fieldlayers in r2024.
      I want to add a layer to a fieldlist. In r2023 it worked quite fine. Now I get a reference Error.
      But when I print anything, the error is not raised.
      In my example I use a python generator, but it seems to happen with a python tag, too.
      Or am I using/inserting the fieldlayers wrong?

      cheers sebastian

      python generator :

      import c4d
      
      def main() -> c4d.BaseObject:
          obj = c4d.BaseObject(c4d.Ocube)
          res = c4d.utils.SendModelingCommand( c4d.MCOMMAND_MAKEEDITABLE, [obj], c4d.MODELINGCOMMANDMODE_ALL, doc = doc )
          if not res: print("error")
          else: obj = res[0].GetClone()
      
          vertex_tag = obj.MakeVariableTag( c4d.Tvertexmap, len(obj.GetAllPoints()) )
          vertex_tag.SetName( "vertex_highlight_reinforce" )
          vertex_tag[c4d.ID_TAGFIELD_ENABLE] = 1
          fields = vertex_tag[c4d.ID_TAGFIELDS]
      
          f_layer_1 = c4d.modules.mograph.FieldLayer( c4d.FLquantize )
          fields.InsertLayer( f_layer_1 )
      
          vertex_tag[c4d.ID_TAGFIELDS] = fields
         
          #print ("")   # with print active, no error will be raised
      
          return obj
      

      results in the following error:
      ReferenceError: the object 'c4d.modules.mograph.FieldLayer' is not alive

      fieldlayer issue 01.c4d

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @datamilch
        last edited by

        Hi Sebastian,

        In case you're using SendModelingCommand outside from the main thread you should use dummy document instead of active document as mentioned in the corresponding docs and in our Threading Manual.

        When one struggles with such an issue usually the first step is to check the code on the main thread (i.e. in the script manager). However, in this case there's something fishy happening when inserting field layer to the field list. I have created a bug report about this issue. Thanks for sharing your experience!

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

        D 1 Reply Last reply Reply Quote 0
        • i_mazlovI i_mazlov moved this topic from Cinema 4D SDK on
        • D
          datamilch @i_mazlov
          last edited by datamilch

          hi ilia @i_mazlov,
          thaks for the advice about threading and the dummy document and the fishy part.

          I continued testing the last days and noticed that it seems to work, when i insert a clone of the fieldlayer.

          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by

            Hey thanks for the report, I indeed fix one issue with the InsertLayer but in your case it was another one, sadly there is no workaround for you (except the one you found).

            The fix will be provided in the next release.
            Cheers,
            Maxime.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • First post
              Last post