From 12c2f8a33d294ed015f1a150cef4272547205ada Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Tue, 12 Feb 2019 19:34:53 -0500 Subject: [PATCH] Fix issue causing PFMs to crash in PotS Recall that PFMs are added as modules to the global modules dict. Therefore, module names must be valid Python 2.x identifiers. This is handled well for age names, but we've been neglecting to handle it for PFM names. So, when Blender adds ".001" as a suffix to a duplicated object, any attached PFMs will go down in a firey dust explosion. Generally, with the unhelpful error message: "NULL result without error in PyObject_Call". --- korman/nodes/node_python.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/korman/nodes/node_python.py b/korman/nodes/node_python.py index f92449d..c0ca09d 100644 --- a/korman/nodes/node_python.py +++ b/korman/nodes/node_python.py @@ -19,6 +19,7 @@ from contextlib import contextmanager from pathlib import Path from PyHSPlasma import * +from ..korlib import replace_python2_identifier from .node_core import * from .node_deprecated import PlasmaVersionedNode from .. import idprops @@ -305,6 +306,12 @@ class PlasmaPythonFileNode(PlasmaVersionedNode, bpy.types.Node): if i.attribute_id == idx: yield i + @property + def key_name(self): + # PFM names ***must*** be valid Python identifiers, but Blender likes inserting + # periods into the object names "Foo.001" -- this causes bad internal chaos in PotS + return replace_python2_identifier("{}_{}".format(self.id_data.name, self.name)) + def _make_attrib_socket(self, attrib, is_init=False): new_pos = len(self.inputs) if not is_init: