Get the preview images from c4d files
-
I saw you can browse a folder of files and get the file informations here:
https://developers.maxon.net/docs/cpp/2023_2/page_manual_browsefiles.htmlIs it also possible to get the preview images from those files? And how?
-
https://forums.cgsociety.org/t/set-preview-in-content-browser-via-python-script/2056787
Not certain it solves your problem but in this post somebody changed the preview picture in python.
https://developers.maxon.net/forum/topic/7666/9673_set-document-preview/2
-
not really
you can get the preview from a BaseDocument with GetDocPreviewBitmap();
but this works only with loaded files, and i don't want to load all files first. -
Hi,
I guess you are talking about retrieving the preview of c4d files only. If you want to retrieve preview of any kind of files, you need to use the OS functionalities and of course they are different if you are using windows or OSX.
But for c4d files you can proceed like so. You have to load the document to have access to the bitmap, but you can do it with the flag
SCENEFILTER::NONE
that way, the minimum will be loaded.#include "maxon/apibase.h" #include "maxon/errorbase.h" #include "maxon/errortypes.h" #include "maxon/url.h" #include "maxon/iobrowse.h" #include "maxon/fileformat_handler.h" #include "maxon/dataformat.h" #include "c4d_general.h" #include "c4d_commanddata.h" #include "c4d_baseplugin.h" #include "c4d_basedocument.h" #include "c4d_basebitmap.h" #include "lib_description.h" #include "customgui_bitmapbutton.h" static maxon::Result<void> pc14103(BaseDocument* doc) { iferr_scope; maxon::Url baseDirectory { maxon::URLSCHEME_FILESYSTEM }; baseDirectory.SetPath("D:/temp/c4d"_s) iferr_return; for (const auto& it : baseDirectory.GetBrowseIterator(maxon::GETBROWSEITERATORFLAGS::NONE)) { const maxon::Url filePath = it.GetCurrentPath() iferr_return; if (filePath.GetSuffix() == "c4d"_s) { Filename maxonFile = MaxonConvert(filePath); BaseDocument* myDoc = LoadDocument(maxonFile, SCENEFILTER::NONE, nullptr); if (myDoc == nullptr) continue; BaseBitmap* docPreview = myDoc->GetDocPreviewBitmap(); if (docPreview && (docPreview->GetBw() > 0) && (docPreview->GetBh() > 0)) ShowBitmap(docPreview); KillDocument(myDoc); } } return maxon::OK; }
Cheers,
Manuel -
thanks that works.