Is it possible to make a PY script, that “scans” whatever is selected in the viewport. Object by Object. And take all it properties and shapes and save it into the text editor.
Like a generator or cloning device python script hehe
Let’s imagine a user creating a female head, and wants to store it as a PY script, so you could go anytime, “create female head”
@aermartin, you can do this for instance… (one object for the example), this dumps rna values to a script but it wont save mesh data for re-generation, for that youll need a script which deals mesh meshes and verts especially for the case you want.
import bpy
data = bpy.context.object
data_str = "bpy.context.object"
for attr in sorted(dir(data)):
if attr.startswith("_"):
continue
value = getattr(data, attr, Ellipsis)
if value is not Ellipsis:
# can it be set at all?
try:
setattr(data, attr, value)
except:
value_error = attr + " is readonly"
value = Ellipsis
if value is not Ellipsis:
# can it be converted from a string?
try:
value = eval(repr(value))
value_error = ""
except:
value = Ellipsis
value_error = repr(value)
if value is Ellipsis and value_error:
print("# %s.%s = %s # can't be set!" % (data_str, attr, repr(value)))
else:
print("%s.%s = %s" % (data_str, attr, repr(value)))
this script avoids any specific type checking, just uses a stupid try/except approach