-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmodel.py
58 lines (49 loc) · 2.08 KB
/
model.py
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
# Copyright vanous
#
# This file is part of BlenderDMX.
#
# BlenderDMX is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# BlenderDMX 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 General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
import bpy
from .gdtf import DMX_GDTF
from .logging import DMX_Log
import traceback
class DMX_Model:
# Return the fixture model collection by profile
# If not imported, build the collection from the GDTF profile
# This collection is then deep-copied by the Fixture class
# to create a fixture collection.
@staticmethod
def getFixtureModelCollection(profile, dmx_mode, display_beams, add_target):
collections = bpy.data.collections
# Make sure the profile was passed as an argument, otherwise return None
if profile == None:
return None
name = DMX_GDTF.getName(profile, dmx_mode, display_beams, add_target)
# If the fixture collection was already imported for this model
# just return it
if name in collections:
DMX_Log.log.debug(f"Getting collection from cache: {name}")
return collections[name]
# Otherwise, build it from profile
try:
new_collection = DMX_GDTF.buildCollection(
profile, dmx_mode, display_beams, add_target
)
except Exception as e:
DMX_Log.log.error(f"Error {e}")
DMX_Log.log.error(f"Traceback: {traceback.print_exception(e)}")
if name in collections:
collections.remove(collections[name])
return None
return new_collection