@@ -163,14 +163,32 @@ class BFCollection:
163
163
Extension of Blender Collection.
164
164
"""
165
165
166
+ def get_layer_collection (self , context , _layer_collection = None ):
167
+ """!
168
+ Return related layer_collection in current context.
169
+ @param context: the Blender context.
170
+ @param _layer_collection: internal use for recursivity.
171
+ @return layer_collection related to self in current context.
172
+ """
173
+ if not _layer_collection :
174
+ _layer_collection = context .view_layer .layer_collection
175
+ found = None
176
+ if _layer_collection .name == self .name :
177
+ return _layer_collection
178
+ for c in _layer_collection .children :
179
+ found = self .get_layer_collection (context , _layer_collection = c )
180
+ if found :
181
+ return found
182
+
166
183
def to_fds (self , context ):
167
184
"""!
168
185
Return the FDS formatted string.
169
186
@param context: the Blender context.
170
187
@return FDS formatted string, eg. "&OBST ID='Test' /".
171
188
"""
172
- if self .hide_render :
173
- return
189
+ layer_collection = self .get_layer_collection (context )
190
+ if self .hide_render or layer_collection .exclude :
191
+ return # exclude from exporting
174
192
obs = list (self .objects )
175
193
obs .sort (key = lambda k : k .name ) # alphabetic by name
176
194
lines = list (ob .to_fds (context ) for ob in obs )
@@ -187,6 +205,7 @@ def register(cls):
187
205
@param cls: class to be registered.
188
206
"""
189
207
Collection .to_fds = cls .to_fds
208
+ Collection .get_layer_collection = cls .get_layer_collection
190
209
191
210
@classmethod
192
211
def unregister (cls ):
@@ -195,6 +214,7 @@ def unregister(cls):
195
214
@param cls: class to be unregistered.
196
215
"""
197
216
del Collection .to_fds
217
+ del Collection .get_layer_collection
198
218
199
219
200
220
class BFScene :
0 commit comments