-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmodel.py
42 lines (35 loc) · 1.38 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
#
# BlendexDMX > Model
# Handles the creation of different models
#
# http://www.github.com/open-stage/BlenderDMX
#
import bpy
from dmx.gdtf import DMX_GDTF
from dmx.logging import DMX_Log
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}")
if name in collections:
collections.remove(collections[name])
return None
return new_collection