Skip to content

Commit a4f4264

Browse files
committed
fix: preserve colors when loading models from JSON - Added color preservation, fixed color assignment to structural elements
1 parent 593dbbd commit a4f4264

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

gempy/modules/json_io/json_operations.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ def load_model_from_json(file_path: str):
200200
if fault_relations.shape == (len(model.structural_frame.structural_groups), len(model.structural_frame.structural_groups)):
201201
model.structural_frame.fault_relations = fault_relations
202202

203+
# Set colors for each element
204+
for series in data['series']:
205+
if 'colors' in series:
206+
for surface_name, color in zip(series['surfaces'], series['colors']):
207+
element = model.structural_frame.get_element_by_name(surface_name)
208+
if element is not None:
209+
element.color = color
210+
203211
return model
204212

205213
@staticmethod

0 commit comments

Comments
 (0)