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)?
ivodow
@ivodow
Posts made by ivodow
-
RE: Thinking Particles allocation failure in new document
-
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()
-
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?
-
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?
-
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.
-
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.
-
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 youS22.118
Windows 10import 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()
-
RE: Alembic Export Options Not Working
Seems to be an initialization/ caching issue. I found 2 workarounds:
- Open the Alembic Export Dialog manually, then hit Cancel, before running the script.
-or-
- Toggle the state of each export setting in the script, as follows:
abcExport[c4d.ABCEXPORT_SELECTION_ONLY] = False abcExport[c4d.ABCEXPORT_SELECTION_ONLY] = True
-
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.pyand 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()