Repository navigation
Expand file tree
/
Copy pathPrism_Set_Global_Texture_Functions.py
More file actions
105 lines (92 loc) · 3.38 KB
/
Copy pathPrism_Set_Global_Texture_Functions.py
File metadata and controls
105 lines (92 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# -*- coding: utf-8 -*-
#
####################################################
#
# PRISM - Pipeline for animation and VFX projects
#
# www.prism-pipeline.com
#
# contact: contact@prism-pipeline.com
#
####################################################
#
#
# Copyright (C) 2016-2023 Richard Frangenberg
# Copyright (C) 2023 Prism Software GmbH
#
# Licensed under GNU LGPL-3.0-or-later
#
# This file is part of Prism.
#
# Prism is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Prism is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Prism. If not, see <https://www.gnu.org/licenses/>.
import sys
c4d_python_path = r"C:\Program Files\Maxon Cinema 4D 2024\resource\modules\python\libs\python311"
if c4d_python_path not in sys.path:
sys.path.append(c4d_python_path)
import c4d
import re
import os
import traceback
try:
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2.QtCore import QTimer
except:
from PySide.QtCore import *
from PySide.QtGui import *
from PrismUtils.Decorators import err_catcher_plugin as err_catcher
class Prism_Set_Global_Texture_Functions(object):
def __init__(self, core, plugin):
self.core = core
self.plugin = plugin
self.texturePath = [r"place-your-master-texture-path",True]
self.texturePath_contained = ["",True]
QTimer.singleShot(5000,self.setupTexturePathContained)
# print(dir(core))
def getActiveProject(self):
try:
return self.core.projectName
except AttributeError:
print("Project name is not available yet.")
return None
except Exception as e:
print(f"An unexpected error occurred: {e}")
return None
def setupTexturePathContained(self):
project_name = self.getActiveProject()
if project_name:
base_path = r"\TemplateFolder"
self.texturePath_contained[0] = f"{base_path}\\{project_name}\\04_Resources"
print("Gathered project name is:", self.texturePath_contained[0])
self.setGlobalTexture()
else:
QTimer.singleShot(1000, self.setupTexturePathContained) # Retry after a delay
def setGlobalTexture(self):
print('Entering setGlobalTexture method')
texturePaths = [
self.texturePath,
self.texturePath_contained
]
try:
print('Setting asset paths:', texturePaths)
c4d.SetGlobalTexturePaths(texturePaths)
print('Asset paths updated:', c4d.GetGlobalTexturePaths())
except Exception as e:
print(f"Error setting global texture paths: {e}")
traceback.print_exc()
@err_catcher(name=__name__)
def isActive(self):
print("Checking if plugin is active")
return True