Created by: zeffii
Addressed problem description
Recently blender API changed for the search_prop ui element, users use this ui feature to search through data-blocks (bpy.data.*
like: materials, texts, fonts, images, objects, collections).
Blender devs have changed the return value when search_prop is used in conjunction with a StringProperty by adding 3 extra characters to the start of the object name.
in Sverchok nodes we have used a StringProperty
to store the names of objects that we reference in the node tree.. The problem with that approach is that when the user renames a datablock, the StringProperty is not automatically renamed, this results in a 'link being lost'. Because naming is important in Graphics and Modelling scenes, just as it is with programming, it is important to be able name and rename objects to reflect what they are.
At runtime we should be storing object references (object in the broader sense...anything in bpy.data.*
) primarily as PointerProperties, and only then store the object.name
if it's useful, and for iojson serialization.
Solution description
The beast is broken. Nodes that use prop_search, and there are many, will be revised. There are two approaches
- switch entirely to the PointerProperty for most existing nodes, and all new nodes.
- name_texture: StringProperty(
- name='Texture',
- description='Texture(s) to evaluate',
- default='',
- update=updateNode)
+ texture_pointer: PointerProperty(
+ name="Texture",
+ poll=lambda self, object: True, # no filtering, this may be optional.
+ type=bpy.types.Texture, # what kind of objects are we showing
+ update=updateNode)
+ # iojson must skip pointers, and implement `storage_get/set_data`
+ properties_to_skip_iojson = ['texture_pointer']
- add a temporary fix that is aware that StringProperty will include extra characters, and perform the lookup accordingly.
texture = self.get_bpy_data_from_name(self.name_texture, bpy.data.textures)
fixes will need to be tested, most importantly for and
Preflight checklist
Now
-
Code changes complete. -
sockets.py socket has 3 props now, instead of 1 ( object_ref
) -object_kinds
-object_ref
-object_ref_pointer
-
object_kinds
(a string) accepts a single or multiple comma separated object types like: -socket.object_kinds = "MESH"
or -socket.object_kinds = "MESH,CURVE"
or -socket.object_kinds = "ALL"
or=""
(empty string) to throughput all object types - We could also dosocket.object_kinds = "sverchok.cat.node.filter_func_name"
-
object_ref
the socket will use any existing reference to this property until the user picks a new object at which point Sverchok will start using theobject_ref_pointer
.
-
-
node_tree.py (merged already) - implements
get_bpy_data_from_name(self, identifier, bpy_data_kind)
which broadly accepts either a direct bpy.types.Object type or a String that represents the object.name, this function tries to "fuzzily" locate the datablock associated with identifier.
- implements
-
generator\script1_lite.py (merged already) +
-
generators_extended\profile_mk3.py +
-
scene\collection_picker_mk1.py +
-
script\multi_exec.py +
-
script\sn_functor_b.py +
-
generators_extended\mesh_eval.py +
-
object_nodes\get_asset_properties.py (now mk2) -
scene\FCurve_in.py -
generator\image.py -
text\text_in_mk2.py +
-
text\text_out_mk2.py +
-
viz\viewer_texture_lite.py ( image file ) -
viz\viewer_typography.py ( font file ) -
transforms\texture_displace.py (now mk2) -
vector\texture_evaluate.py (now mk2) -
viz\viewer_polyline.py ( bevel object, has filter Curves now! ) -
scene\node_remote.py (now mk2) -
scene\dupli_instances_mk4.py
-
-
Code documentation complete. -
Documentation for users complete (or not required, if user never sees these changes). -
Manual testing done. -
Ready for merge.
Later
- [ ] generators_extended\hilbert_image.py
- [ ] generators_extended\generative_art.py
- [ ] field\image_field.py
- [ ] object_nodes\assign_materials.py
- [ ] object_nodes\color_uv_texture.py
- [ ] object_nodes\points_from_uv_to_mesh.py
- [ ] object_nodes\sample_uv_color.py
- [ ] analyzer\image_components.py
- [ ] **sv_obj_helper**: (materials ! )
- the mixin will need to set pointerproperty and keep stringproperty for a while.
- [ ] viz\viewer_bmesh.py (material prop_search for 3dview.. resolve with obj_helper first)