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. ivodow
    3. Posts
    I
    • Profile
    • Following 0
    • Followers 0
    • Topics 4
    • Posts 13
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by ivodow

    • RE: Thinking Particles- How to Set "Settings"

      Okay, thank you again.

      posted in Cinema 4D SDK
      I
      ivodow
    • RE: Thinking Particles- How to Set "Settings"

      Hi Manuel,

      Thank you for your answer, I appreciate it.

      So that in the future I can find these things myself, I tried searching searching your Python docs for TP_VIEWTYPE. No results were returned. I assume those #defines are drawn from a C++ header, so I tried searching for TP_VIEWTYPE here, also with no success.

      Where can I find full searchable API documentation for Cinema 4D? (Like that for Rhino Common)

      posted in Cinema 4D SDK
      I
      ivodow
    • Thinking Particles- How to Set "Settings"

      In Simulate -> Thinking Particles -> TP Settings... there are a series of UI elements at the top of the General tab controlling global settings for the TP system:

      Max. Particles
      Force this Setting
      Show Objects
      View Type

      How do I set these from python? (I specifically need Max Particles and View Type.) I have been all over the docs and cannot seem to find them.

      Thank you.

      posted in Cinema 4D SDK r23 python
      I
      ivodow
    • RE: Write to C4D console in real time

      An answer to my initial question, for others who may encounter the same issue. This can be used in lieu of print()

      import maxon
      
      def ConsolePrint( *args ):
          # concatenate var args into a single, space separated string suitable for maxon.Loggers
          txt = " ".join(str(i) for i in args)
          maxon.Loggers.Python().Write( maxon.TARGETAUDIENCE.ALL, txt, maxon.MAXON_SOURCE_LOCATION(1), maxon.WRITEMETA.UI_SYNC_DRAW )
      
      if __name__ == "__main__":
      
         ConsolePrint( "Output" )
      
      posted in Cinema 4D SDK
      I
      ivodow
    • RE: Thinking Particles allocation failure in new document

      Thank for the additional information.
      So, would ExecutePasses() with the BUILDFLAGS_EXPORT flag set be typically called just before exporting to alembic (to be on the safe side)?

      posted in Cinema 4D SDK
      I
      ivodow
    • RE: Write to C4D console in real time

      Here is a contrived minimal working example that demonstrates the issue. This is only intended to force the issue to occur. My actual code involves loading multiple >2 GB databases and building particle systems.

      Thank you.

      
      import c4d
      
      
      def long_process():
      
          fullpath = c4d.storage.LoadDialog( type = c4d.FILESELECTTYPE_IMAGES, title = "Select File > 10MB:" )
          if not fullpath:
              return
      
          for n in xrange( 10 ):
      
              cnt = 0
              with open( fullpath, 'rb') as f:
                  while( True ):
                      ansi_byte = f.read(1)
                      if( ansi_byte == b'' ):
                          break
                      if( cnt % 100000 == 0 ):
                          print( "Scanned " + str(cnt) + " bytes..." )
                      cnt += 1
      
              print( "Pass: " + str(n) )
      
      
      if __name__ == "__main__":
      
          c4d.CallCommand( 13957 )
      
          print( "Start" )
      
          long_process()
      
          print( "End" )
      
          c4d.EventAdd()
      
      posted in Cinema 4D SDK
      I
      ivodow
    • RE: Write to C4D console in real time

      I found c4d.CallCommand( 13957 ), which clears the console and posts any buffered lines.

      However, what I'd like to do is post the buffered lines without clearing. Is this possible?

      posted in Cinema 4D SDK
      I
      ivodow
    • Write to C4D console in real time

      Hi,

      I have a script that takes a long time to complete, and I would like to keep an eye on progress.

      Is it possible for print() or WriteConsole() events to immediately be posted to the python console, rather than all posted after the script returns control to c4d? If not, is there another way in the c4d api to accomplish this?

      posted in Cinema 4D SDK python
      I
      ivodow
    • RE: Thinking Particles allocation failure in new document

      Manuel,

      Thank you very much for the workaround.

      Can you tell me more about what ExecutePasses() does, and when it should be normally be called? I am also having an issue where exporting large numbers of scripted particles to alembic (again, by scripting) is creating a nearly empty file. I see the flag BUILDFLAGS_EXPORT on ExecutePasses() and wonder if that might do the trick.

      posted in Cinema 4D SDK
      I
      ivodow
    • RE: Thinking Particles allocation failure in new document

      I also tried creating the new document with c4d.CallCommand(12094). AllocParticle() failed with this approach as well.

      posted in Cinema 4D SDK
      I
      ivodow
    • Thinking Particles allocation failure in new document

      Hi,
      A minimal example to reproduce my issue is posted below. Am I missing a step?
      Please advise...
      Thank you

      S22.118
      Windows 10

      import c4d
      
      def main():
          temp_document = c4d.documents.BaseDocument()
          c4d.documents.InsertBaseDocument( temp_document )
          c4d.documents.SetActiveDocument( temp_document )
      
          pSys = temp_document.GetParticleSystem()
          if pSys is None:
              raise RuntimeError("Failed to retrieve Thinking Particle System from Document.")
      
          particle_id = pSys.AllocParticle()
          if particle_id == c4d.NOTOK:
              raise RuntimeError("particle_id == c4d.NOTOK" )
      
      # Execute main()
      if __name__=='__main__':
          main()
      
      posted in Cinema 4D SDK python s22
      I
      ivodow
    • RE: Alembic Export Options Not Working

      Seems to be an initialization/ caching issue. I found 2 workarounds:

      1. Open the Alembic Export Dialog manually, then hit Cancel, before running the script.

      -or-

      1. Toggle the state of each export setting in the script, as follows:
          abcExport[c4d.ABCEXPORT_SELECTION_ONLY] = False
      
          abcExport[c4d.ABCEXPORT_SELECTION_ONLY] = True
      
      
      posted in Cinema 4D SDK
      I
      ivodow
    • Alembic Export Options Not Working

      Hi,

      S22.016(RC)

      I am attempting to make an automated Alembic thinking particle exporter, and I have run into an issue where setting the export options does not work.

      Copying directly from the dev example here:
      https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/master/scripts/03_application_development/files_media/export_alembic_r14.py

      and only changing a few of the export options. Script does not work properly, as the resulting .abc file exported DOES contain all objects (not just the selection, as specified), and does NOT contain the particles.

      Please advise me.

      Thank you.

      """
      Copyright: MAXON Computer GmbH
      Description:
          - Exports Alembic with custom settings.
      Class/method highlighted:
          - c4d.plugins.FindPlugin()
          - MSG_RETRIEVEPRIVATEDATA
          - c4d.documents.SaveDocument()
      Compatible:
          - Win / Mac
          - R14, R15, R16, R17, R18, R19, R20, R21, S22
      """
      import c4d
      
      
      def main():
          # Retrieves a path to save the exported file
          filePath = c4d.storage.LoadDialog(title="Save File for Alembic Export", flags=c4d.FILESELECT_SAVE, force_suffix="abc")
          if not filePath:
              return
      
          # Retrieves Alembic exporter plugin, 1028082, defined in R20.046 as FORMAT_ABCEXPORT
          abcExportId = 1028082 if c4d.GetC4DVersion() < 20046 else c4d.FORMAT_ABCEXPORT
          plug = c4d.plugins.FindPlugin(abcExportId, c4d.PLUGINTYPE_SCENESAVER)
          if plug is None:
              raise RuntimeError("Failed to retrieve the alembic exporter.")
      
          data = dict()
          # Sends MSG_RETRIEVEPRIVATEDATA to Alembic export plugin
          if not plug.Message(c4d.MSG_RETRIEVEPRIVATEDATA, data):
              raise RuntimeError("Failed to retrieve private data.")
      
          # BaseList2D object stored in "imexporter" key hold the settings
          abcExport = data.get("imexporter", None)
          if abcExport is None:
              raise RuntimeError("Failed to retrieve BaseContainer private data.")
      
          # Defines Alembic export settings
          abcExport[c4d.ABCEXPORT_SELECTION_ONLY] = True
          abcExport[c4d.ABCEXPORT_PARTICLES] = True
          abcExport[c4d.ABCEXPORT_PARTICLE_GEOMETRY] = True
      
          # Finally export the document
          if not c4d.documents.SaveDocument(doc, filePath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, abcExportId):
              raise RuntimeError("Failed to save the document.")
      
          print("Document successfully exported to:", filePath)
      
      
      if __name__ == '__main__':
          main()
      
      posted in Cinema 4D SDK python s22
      I
      ivodow