Thank you for the answer @ferdinand . Sorry for the decay of the follow up posts, im used to posting all attempted solutions, so that future readers have a guide.
We solved the problem by converting in a seperate Plugin call and it seems the legacy code im working on, "accidentally" reduced the context switch stale objects, by regularly re-storing the document refrence from a old reference kept in main. Your answers have been very useful and highlight important concepts developers should be well aware off. Thanks gain.
Not certain it solves your problem but in this post somebody changed the preview picture in python.
Thanks for explaining Manual
Hi, i encountered a problem using paths containining Umlauts in my code. Im trying to rename Customer Texture files which have Umlauts in there names.
I traverse the folder, glue the filenames together which does not produce any error.
originalFilePathAsciiiUTF8Mix = os.path.join(srcFolder, 'tex', originalFileName)
However when i try to use the concated path, with file.open or shutil.copy2 the path is not found and the displayed path in the error message seems to be a strange mixture of properly escaped ascii symbols and not escaped UTF8 elements.
I printed out the path as hexValues and the values look like a classic ascii (no codepage) string (not clear on what codepage) and raw UTF8 Values in the middle.
originalFilePathAsciiLatin1 -> |C=43|:=3a|\=5c|T=54|e=65|s=73|t=74|\=5c|I=49|n=6e|p=70|u=75|t=74|\=5c|4=34|3=33|4=34|6=36|9=39|\=5c|4=34|3=33|4=34|6=36|9=39|\=5c|t=74|e=65|x=78|\=5c|k=6b|i=69|e=65|f=66|e=65|r=72|_=5f|g=67|e=65|f=66|l=6c|=c3|=a4|m=6d|m=6d|t=74|_=5f|1=31|.=2e|j=6a|p=70|e=65|g=67
So ive read into encodings and utf8 in Python 2.7 and boy, what a rabbit hole.
My question is, how can i convert this "hybrid" into a valid utf8 representation and finally into a path that the services used by shutil and os.copy can handle.
originalFilePath = originalFilePathAsciiiUTF8Mix.decode('utf-8').encode('cp1250')
Hi, i encounter a bug with Cinema4D. The problem is that the bug is not deterministic. Converting this file worked before and now errors out. _BugReport.txt
I looked into the bug report and noticed i filed a similar bug to corona.
They recommended i delete the leftover shaders or materials. So is this a running out of memory bug?
My code depends on another Plugin to be completely loaded before it can be executed. How do ich check this in Code?
I once got advice from @ferdinand to wait for All-Plugins-Start:
"..I assume it is a plugin tied into PluginStart()? Be aware that depending on the plugin message, Cinema 4D might not yet have booted fully, you should not rely on the active document and similar things before C4DPL_STARTACTIVITY has been emitted. The earlier you are in the boot process, the less libraries and systems will work.."
But i logged those out and it always seemed to be called before the commandline arguments are processed. If this is recieved what guarantees do i have on the other plugin black boxes?
That all have completed loading? Including gui-components? Is there another way to check if any plugin python is busy in the background?
We life and learn.
Turns out one must select the material tag with
before calling the command
to bake the projection down, down into the ground. It now works as intended.
Im assiging UVs in Script,
and have the problem that i dont seem to be able to convert a CUBIC_PROJEKTION on a object down into UVs that would persist outside of the Cinema4D format.
My collague gave me the advice to perform the equivalent to Assign_UVS in code and i researched and found the command IDM_ASSIGN_UVW in C4D_Symbols.h but it has no Numbercode to call mapped to it.
How do i call this command in scfript?
I know of GENERATE_UV_COORDS with 12235. But this
c4d.CallCommand(CMD.GENERATE_UV_COORDS, CMD.GENERATE_UV_COORDS) # Generate UV Coordinates
does not "bake" the CUBIC projection down.
Hi im converting Materials using the Corona To C4D Plugin,
and im running into a strange problem, were my the context for my doc seems to go missing. But first thing first:
I convert using the Cinema 4D exe as commandline, as the plugin otherwise does not seem to convert and store the information.
"Cinema 4D.exe" -nogui etc. etc..
This gives me very little commandline error output, making it very hard to debug, but its the only workaround i got for now. Se la vie.
I call my converter module giving it a doc reference and storing the document reference upon return
cac = CoronaAuraConverter.Converter(clone)
cloneResult = cac.main(clone, self, dst)
clone = cloneResult
In the converter submodule i process using the following code. This is because i can not seem to acess the converted materials until i saved and reload the document. This has been profen to work in a minimal sandbox example.
def main(self, doc, vuframeAuraInstanceRef, dst):
#Conversion process copied from Sandbox
tempORaryFilePath = self.tools.path_replace_leaf( dst, "tempStorageForMaterialDrop.c4d")
LogWithTimestamp("TempoaryFilePath " + tempORaryFilePath)
documents.SaveDocument(doc, tempORaryFilePath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_C4DEXPORT)
newDoc = Tools.loadActiveDocumentFrom(tempORaryFilePath)
allMats = newDoc.GetMaterials()
for mat in allMats:
LogWithTimestamp("Storing Material Standard Info:" + mat.GetName())
#Doing work with the loaded materials - this work
Upon return working with the returned old doc reference seems to fail.
I tried to refresh it with
doc = documents.GetActiveDocments()
assumption being its some context reference going stale and getting gcc or similar.
Anyone any idea were i did go wrong. Also a way to get the standard output beyond 25 kb by g_logfile="c4dconversion.log" would be greatly appreciated.
PS: Is there a way to buy SDK-Team Support tickets?
PS: Just for completness, not relevant as it loads the document
print "DEBUG: file exists :" + str(os.path.exists(src))
load = documents.LoadFile(src)
if not load:
LogWithTimestamp( "Source File could not be loaded: " + src)
raise FileNotFoundError("Source file at path " +src + " not found")
doc = documents.GetActiveDocument()
if doc is None:
LogWithTimestamp( "Could not get active document")
Thanks did report