On 11/06/2015 at 13:06, xxxxxxxx wrote:
I believe the metadata is with .c4d scene file. Is there any documents I can look up to access the metadata? As for now, what I did is to write out a xml file as a temporary solution.
If there is accessible metadata it would be so much helpful. Thank you!
On 12/06/2015 at 06:50, xxxxxxxx wrote:
Hello and welcome,
I guess with metadata you mean the project infos like author, copyright and file version? You can access that information from the BaseDocument using GetDocumentData():
data = doc.GetDocumentData(c4d.DOCUMENTSETTINGS_DOCUMENT) print(data[c4d.DOCUMENT_INFO_AUTHOR]) print(data[c4d.DOCUMENT_INFO_PRGCREATOR_NAME])
See also this thread: "Extracting Metadata".
On 12/06/2015 at 09:20, xxxxxxxx wrote:
Thank you for your information, I will try it out. Thanks!!
On 12/06/2015 at 10:16, xxxxxxxx wrote:
I would like to set/get new settings to/from the document using BaseContainer, but I am not sure how to combine both DocumentData and BaseContainer. Below is the code I was trying to add the data from BaseContainer to DocumentData, and of course it's not working.. Sebastian would you mind take a look? Thanks!
bc = c4d.BaseContainer()
setData = doc.SetDocumentData(c4d.DOCUMENTSETTINGS_DOCUMENT, bc)
TypeError: an integer is required
I assume it should be a new type for bc?
Once the data has been stored to the document, I can also get the value from it.
On 12/06/2015 at 16:05, xxxxxxxx wrote:
Hi @Amy, something like this should work:
toggle_bc = c4d.BaseContainer() toggle_bc[TOGGLE_ID] = True doc[PLUGIN_ID] = toggle_bc
From this post.
Not sure what the error in your code is.
On 15/06/2015 at 10:21, xxxxxxxx wrote:
Thank you Donovan, I could set and get the customized setting now :)
Just in case anyone have the similar need, below is the code:
store data to document
bc = c4d. BaseContainer()
bc[id] = value
access data from the document
mdata = doc.GetDocumentData(c4d.DOCUMENTSETTINGS_DOCUMENT)
dataValue = mdata[id]
On 15/06/2015 at 10:44, xxxxxxxx wrote:
That actually looks a little dangerous - you're storing a mostly empty container in the DOCUMENTSETTINGS_DOCUMENT slot - if anyone else is trying to store data there you'll overwrite it. It would be safer to do something like:
#Create a container to store your custom data plugin_bc = c4d.BaseContainer() plugin_bc[item_id] = value #Get the Document Settings BaseContainer doc_bc = doc.GetDocumentData(c4d.DOCUMENTSETTINGS_DOCUMENT) doc_bc[PLUGIN_ID] = plugin_bc #Store plugin container inside of document container #Save the updated Document BC doc.SetDocumentData(c4d.DOCUMENTSETTINGS_DOCUMENT, doc_bc) #Access data from the document dataValue = doc.GetDocumentData(c4d.DOCUMENTSETTINGS_DOCUMENT)[PLUGIN_ID][ITEM_ID] #It would probably be safer to check to ensure the container is returned and your subcontainer exists before using it.
You can get a unique plugin id here: http://www.plugincafe.com/forum/developer.asp
On 15/06/2015 at 10:47, xxxxxxxx wrote:
Oh, good to know! Thank you very much, Donovan