About Texture Paths in MergeDocument
-
Hi everyone!
After using MergeDocument to import a file, I need to manually specify the texture paths in the Project Asset Inspector. Am I importing the files incorrectly, or is there an additional setting I need to configure?import c4d def main() -> None: doc = c4d.documents.GetActiveDocument() target_flie = r"D:\01\test.c4d" c4d.documents.MergeDocument(doc, target_flie, c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS | c4d.SCENEFILTER_MERGESCENE) if __name__ == '__main__': main()
-
Hi @Ross,
Welcome to the Maxon developers forum and its community, it is great to have you with us!
Getting Started
Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.
- Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
- Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
- Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.
It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: Asking Questions.
About your First Question
The behavior you're describing is expected and there's no extra flag or other config that could quickly fix it for you. This effectively means that you need to iterate over texture paths and manually change them to the expected form (I assume it's either making them absolute paths or recalculating them relative to the target document location).
Fortunately, there's c4d.documents.GetAllAssetsNew function, which can make things easier for you by retreiving all the assets. It has been nicely explained by Ferdinand in the following thread: API for Project Asset Inspector?. Please also have a look at the almost exact same question that has already been asked: Changing Asset References to Absolute.
For the path calculation part, you might be willing to use the c4d.GenerateTexturePath function, which was designed specifically for this purpose.
Cheers,
Ilia -
@i_mazlov I get it, thanks for your reply.