Skip to content

Commit

Permalink
Fix edit custom property operator
Browse files Browse the repository at this point in the history
  • Loading branch information
malter committed Jul 27, 2022
1 parent ecb0821 commit 0cfa5fb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions phobos/operators/editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
FloatVectorProperty,
BoolVectorProperty,
)
from idprop.types import IDPropertyGroup

import phobos.defs as defs
import phobos.display as display
Expand Down Expand Up @@ -1201,15 +1202,23 @@ def execute(self, context):
# transform Blender id_arrays into lists
if hasattr(tmpdict[key], 'to_list'):
tmpdict[key] = list(tmpdict[key])
cleandict = bUtils.cleanObjectProperties(tmpdict)
# convert to python key value pairs
tmpdict = {}
for key,value in cleandict.items():
if not isinstance(value, IDPropertyGroup):
tmpdict[key] = value
contents = [
variablename + ' = """',
json.dumps(bUtils.cleanObjectProperties(tmpdict), indent=2) + '"""\n',
json.dumps(tmpdict, indent=2) + '"""\n',
"# ------- Hit 'Run Script' to save your changes --------",
"import json",
"import bpy",
"tmpdata = json.loads(" + variablename + ")",
"for key in dict(bpy.context.active_object.items()):",
" del bpy.context.active_object[key]",
" if key not in ['phobostype', 'startChain', 'endChain', '_RNA_UI', 'cycles_visibility', 'masschanged']:",
" if type(bpy.context.active_object[key]) != 'IDPropertyGroup':",
" del bpy.context.active_object[key]",
"for key, value in tmpdata.items():",
" bpy.context.active_object[key] = value",
"bpy.ops.text.unlink()",
Expand Down

0 comments on commit 0cfa5fb

Please sign in to comment.