SaveDocument()
-
On 05/11/2013 at 10:03, xxxxxxxx wrote:
(My apologies in advance, I could not get the formatting for code blocks working properly.)
Is there a way to make SaveDocument() name the current document the name that the file was saved as?
When I use
c4d.documents.SaveDocument(doc, path, c4d.SAVEDOCUMENTFLAGS_DIALOGSALLOWED, c4d.FORMAT_C4DEXPORT)
the file is saved, however, the previous document name remains.
In order to deal with this, I have had to write the following, but I refuse to believe this is the correct way. I have to be missing something.
new_doc = c4d.documents.SaveDocument(doc, path, c4d.SAVEDOCUMENTFLAGS_DIALOGSALLOWED, c4d.FORMAT_C4DEXPORT)
c4d.documents.CloseAllDocuments()
c4d.documents.LoadFile(path)TIA!
-
On 05/11/2013 at 17:00, xxxxxxxx wrote:
@TheAdmiral,
If I understand your question:
- you previously saved your current file as file1.c4d,
-or you opened a file named file1.c4d;
-and now, you want to save it as file2.c4d . -
On 06/11/2013 at 09:42, xxxxxxxx wrote:
BaseDocuments are derived from BaseList2d, so SetName() and GetName() will apply (or the respective identifier).
-
On 06/11/2013 at 10:33, xxxxxxxx wrote:
@Focus3D
I'm really making a script to save incrementally and update all render settings paths to point to the new version. I would use the "Save Incremental" that Maxon is using, but it does not give an option to save to the next available version if the version number you are trying to save as is already taken or update your output paths.
When I run c4d.documents.SaveDocumet(), it saves the file properly, bu the current document keeps the original name.
So if I am in FILE_v001.c4d and I run my script, FILE_v002.c4d exists, my paths have been updated to reflect version v002, but the document name is still FILE_v001
@littledevil
Much appreciated!!
-
On 06/11/2013 at 21:24, xxxxxxxx wrote:
@TheAdmiral,
import os import c4d from c4d import documents, gui def main() : doc = documents.GetActiveDocument() path = "D:\\TestPY\\file5.c4d" newc4dName = os.path.split(path)[1] if newc4dName.endswith('.c4d') : newc4dName = newc4dName[:-4] if os.path.isfile(path) == True: gui.MessageDialog('File Exist!') return if documents.SaveDocument(doc, path, c4d.SAVEDOCUMENTFLAGS_DIALOGSALLOWED, c4d.FORMAT_C4DEXPORT)==True: doc.SetDocumentName(newc4dName) if __name__=='__main__': main()
-
On 07/11/2013 at 09:32, xxxxxxxx wrote:
Thanks Focus.
How about something like this for the 'isfile'.
(Please excuse the use of a 3 button dialog when i should be making one with proper buttons. This is still in testing. Ive also formatted the message string to be semi legible. )
if os.path.isfile(o['new_scn_path']) :
glob_pat = o['new_scn_path'].replace(o['new_ver'], '*')
up_ver = str(int(re.search('_v(\d+)', max(glob.glob(glob_pat))).group(1))+1).zfill(len(o['new_ver']))w = c4d.gui.MessageDialog('The version you are tryng to save as already exists.\n\n
Would you like to SAVE UP to ver '+up_ver+',
OVERWRITE ver'+o['new_ver']+',
or CANCEL this menu?\n\n
YES WILL SAVE UP to ver '+up_ver+',
NO WILL OVERWRITE ver '+o['new_ver']+',
and CANCEL WILL CLOSE this dialog, and kill the script.\n\n
Choose now, go!', 3)if w == 6:
o['new_scn_name'] = o['new_scn_name'].replace('_v'+o['new_ver'], '_v'+up_ver)
o['new_scn_path'] = o['new_scn_path'].replace('_v'+o['new_ver'], '_v'+up_ver)
o['new_ver'] = up_ver
saveIncremental(o)
elif w == 2:
return FalseI also have a function that then walks through the render settings to see which are set to render to paths that have the file's name and/or version number in them, and updates them values accordingly.
-
On 07/11/2013 at 09:33, xxxxxxxx wrote:
Also, am I missing the button for code blocking? It doesn't seem to appear here and using <code> didn't seem to work either.
TIA
-
On 07/11/2013 at 10:13, xxxxxxxx wrote:
@TheAdmiral,
for code use:
"["CODE]put your code here[/CODE"]" (remove all ")
also check <[URL-REMOVED]> for BBcode list.
Enable BBcodes to format post must be checked.I will check your code as soon as finish with my new plugin.
Glad, I was helpfull.
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 07/11/2013 at 10:14, xxxxxxxx wrote:
Awesome! Thanks!