[Bf-extensions-cvs] [5f6f675f] blender2.8: Use collection and instance terminology in Python API
Sergey Sharybin
noreply at git.blender.org
Wed Nov 28 18:23:22 CET 2018
Commit: 5f6f675fc196949ac9210dc5094bed6ab65300a7
Author: Sergey Sharybin
Date: Wed Nov 28 17:51:29 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBAC5f6f675fc196949ac9210dc5094bed6ab65300a7
Use collection and instance terminology in Python API
This follows naming convention agreed on in T56648.
===================================================================
M add_dimension.py
M add_mesh_clusters/__init__.py
M add_mesh_space_tree/__init__.py
M amaranth/misc/dupli_group_id.py
M cacharanth/meshcache.py
M cacharanth/ui.py
M data_overrides/ui.py
M io_atomblend_utilities/io_atomblend_utilities.py
M io_directx_bel/bel/group.py
M io_directx_bel/bel/ob.py
M io_mesh_xyz/import_xyz.py
M io_scene_fpx/fpx_import.py
M object_color_rules.py
M oscurart_mesh_cache_tools.py
M space_view3d_enhanced_3d_cursor.py
M space_view3d_library_hide.py
M space_view3d_toolshelf_menu.py
===================================================================
diff --git a/add_dimension.py b/add_dimension.py
index f78d448b..6468d94d 100644
--- a/add_dimension.py
+++ b/add_dimension.py
@@ -1748,10 +1748,10 @@ def createCurve(vertArray, self, align_matrix):
bpy.ops.object.mode_set(mode = 'OBJECT')
- if group_name in bpy.data.groups:
- group = bpy.data.groups[group_name]
+ if group_name in bpy.data.collections:
+ group = bpy.data.collections[group_name]
else:
- group = bpy.data.groups.new(group_name)
+ group = bpy.data.collections.new(group_name)
if not DimensionCurve.name in group.objects:
group.objects.link(DimensionCurve)
diff --git a/add_mesh_clusters/__init__.py b/add_mesh_clusters/__init__.py
index f384f034..38c1c3a6 100644
--- a/add_mesh_clusters/__init__.py
+++ b/add_mesh_clusters/__init__.py
@@ -356,7 +356,7 @@ def DEF_atom_draw_atoms(prop_element,
ball.active_material = material
ball.parent = new_atom_mesh
- new_atom_mesh.dupli_type = 'VERTS'
+ new_atom_mesh.instance_type = 'VERTS'
# ------------------------------------------------------------------------
# SELECT ALL LOADED OBJECTS
diff --git a/add_mesh_space_tree/__init__.py b/add_mesh_space_tree/__init__.py
index 3f26e98e..629b1423 100644
--- a/add_mesh_space_tree/__init__.py
+++ b/add_mesh_space_tree/__init__.py
@@ -67,12 +67,12 @@ from .timer import Timer
def availableGroups(self, context):
- return [(name, name, name, n) for n, name in enumerate(bpy.data.groups.keys())]
+ return [(name, name, name, n) for n, name in enumerate(bpy.data.collections.keys())]
def availableGroupsOrNone(self, context):
groups = [('None', 'None', 'None', 1)]
- return groups + [(name, name, name, n + 1) for n, name in enumerate(bpy.data.groups.keys())]
+ return groups + [(name, name, name, n + 1) for n, name in enumerate(bpy.data.collections.keys())]
def availableObjects(self, context):
@@ -157,9 +157,9 @@ def halton3D(index):
def insidegroup(pointrelativetocursor, group):
- if bpy.data.groups.find(group) < 0:
+ if bpy.data.collections.find(group) < 0:
return False
- for ob in bpy.data.groups[group].objects:
+ for ob in bpy.data.collections[group].objects:
if pointInsideMesh(pointrelativetocursor, ob):
return True
return False
@@ -169,8 +169,8 @@ def groupdistribution(crowngroup, shadowgroup=None, seed=0, size=Vector((1, 1, 1
pointrelativetocursor=Vector((0, 0, 0))):
if crowngroup == shadowgroup:
shadowgroup = None # safeguard otherwise every marker would be rejected
- nocrowngroup = bpy.data.groups.find(crowngroup) < 0
- noshadowgroup = (shadowgroup is None) or (bpy.data.groups.find(shadowgroup) < 0) or (shadowgroup == 'None')
+ nocrowngroup = bpy.data.collections.find(crowngroup) < 0
+ noshadowgroup = (shadowgroup is None) or (bpy.data.collections.find(shadowgroup) < 0) or (shadowgroup == 'None')
index = 100 + seed
nmarkers = 0
nyield = 0
@@ -199,8 +199,8 @@ def groupExtends(group):
of the bounding box in world space that encapsulates all objects in a group.
"""
bb = []
- if bpy.data.groups.find(group) >= 0:
- for ob in bpy.data.groups[group].objects:
+ if bpy.data.collections.find(group) >= 0:
+ for ob in bpy.data.collections[group].objects:
rot = ob.matrix_world.to_quaternion()
scale = ob.matrix_world.to_scale()
translate = ob.matrix_world.translation
@@ -954,8 +954,8 @@ class SCATree(bpy.types.Operator):
startingpoints = []
if self.useTrunkGroup:
- if bpy.data.groups.find(self.trunkGroup) >= 0:
- for ob in bpy.data.groups[self.trunkGroup].objects:
+ if bpy.data.collections.find(self.trunkGroup) >= 0:
+ for ob in bpy.data.collections[self.trunkGroup].objects:
p = ob.location - context.scene.cursor_location
startingpoints.append(Branchpoint(p, None))
diff --git a/amaranth/misc/dupli_group_id.py b/amaranth/misc/dupli_group_id.py
index 3c42eae1..b131eef2 100644
--- a/amaranth/misc/dupli_group_id.py
+++ b/amaranth/misc/dupli_group_id.py
@@ -73,8 +73,8 @@ def ui_dupli_group_library_path(self, context):
row = self.layout.row()
row.alignment = "LEFT"
- if ob and ob.dupli_group and ob.dupli_group.library:
- lib = ob.dupli_group.library.filepath
+ if ob and ob.instance_collection and ob.instance_collection.library:
+ lib = ob.instance_collection.library.filepath
row.operator(AMTH_SCENE_OT_blender_instance_open.bl_idname,
text="Library: %s" % lib,
@@ -94,7 +94,7 @@ class AMTH_OBJECT_OT_id_dupligroup(bpy.types.Operator):
@classmethod
def poll(cls, context):
- return context.active_object.dupli_group
+ return context.active_object.instance_collection
def execute(self, context):
self.__class__.clear = False
@@ -105,8 +105,8 @@ class AMTH_OBJECT_OT_id_dupligroup(bpy.types.Operator):
obdata = 'bpy.data.objects[" % s"]' % ob.name
# TODO: cleanup script var using format or template strings
script = "%s" % (
- "\nif %(obdata)s and %(obdata)s.dupli_group and %(obdata)s.pass_index != 0: %(obname)s \n"
- " for dob in %(obdata)s.dupli_group.objects: %(obname)s \n"
+ "\nif %(obdata)s and %(obdata)s.instance_collection and %(obdata)s.pass_index != 0: %(obname)s \n"
+ " for dob in %(obdata)s.instance_collection.objects: %(obname)s \n"
" dob.pass_index = %(obdata)s.pass_index %(obname)s \n" %
{"obdata": obdata, "obname": script_intro})
@@ -122,9 +122,9 @@ class AMTH_OBJECT_OT_id_dupligroup(bpy.types.Operator):
amth_text.write(script_intro)
amth_text.write(script)
- if ob and ob.dupli_group:
+ if ob and ob.instance_collection:
if ob.pass_index != 0:
- for dob in ob.dupli_group.objects:
+ for dob in ob.instance_collection.objects:
dob.pass_index = ob.pass_index
self.report({"INFO"},
@@ -143,7 +143,7 @@ class AMTH_OBJECT_OT_id_dupligroup_clear(bpy.types.Operator):
@classmethod
def poll(cls, context):
- return context.active_object.dupli_group
+ return context.active_object.instance_collection
def execute(self, context):
context.active_object.pass_index = 0
@@ -165,7 +165,7 @@ class AMTH_OBJECT_OT_id_dupligroup_clear(bpy.types.Operator):
def ui_object_id_duplis(self, context):
- if context.active_object.dupli_group:
+ if context.active_object.instance_collection:
split = self.layout.split()
row = split.row(align=True)
row.enabled = context.active_object.pass_index != 0
diff --git a/cacharanth/meshcache.py b/cacharanth/meshcache.py
index ef6417bb..b259da40 100644
--- a/cacharanth/meshcache.py
+++ b/cacharanth/meshcache.py
@@ -83,7 +83,7 @@ class MeshcacheOperator():
def poll(cls, context):
if context.scene.meshcache_apply_to == 'GROUP':
# XXX doesn't seem correct
- return bpy.data.groups
+ return bpy.data.collections
else:
return context.active_object is not None
@@ -92,7 +92,7 @@ class MeshcacheOperator():
scene = context.scene
if scene.meshcache_apply_to == 'GROUP':
- objects = bpy.data.groups[scene.meshcache_group].objects
+ objects = bpy.data.collections[scene.meshcache_group].objects
else:
objects = context.selected_objects
diff --git a/cacharanth/ui.py b/cacharanth/ui.py
index eb2c900a..00a680a9 100644
--- a/cacharanth/ui.py
+++ b/cacharanth/ui.py
@@ -43,17 +43,17 @@ class CACHARANTH_GroupSelect(Operator):
bl_description = "Switch to another material in this mesh"
def avail_groups(self,context):
- items = [(str(i),x.name,x.name, "GROUP", i) for i,x in enumerate(bpy.data.groups)]
+ items = [(str(i),x.name,x.name, "GROUP", i) for i,x in enumerate(bpy.data.collections)]
return items
group_select = bpy.props.EnumProperty(items = avail_groups, name = "Available Groups")
@classmethod
def poll(cls, context):
- return bpy.data.groups
+ return bpy.data.collections
def execute(self,context):
- bpy.context.scene.meshcache_group = bpy.data.groups[int(self.group_select)].name
+ bpy.context.scene.meshcache_group = bpy.data.collections[int(self.group_select)].name
return {'FINISHED'}
@@ -135,9 +135,9 @@ class VIEW3D_PT_MeshcacheToolsPanel(Panel):
row.prop(scene, "meshcache_apply_to", expand=True)
if scene.meshcache_apply_to == 'GROUP':
- if bpy.data.groups:
+ if bpy.data.collections:
row = layout.row(align=True)
- row.enabled = len(bpy.data.groups) != 0
+ row.enabled = len(bpy.data.collections) != 0
row.label(text="Select Group:")
row.operator_menu_enum("cacharanth.group_select",
"group_select",
diff --git a/data_overrides/ui.py b/data_overrides/ui.py
index e518cfe2..e4998dcb 100644
--- a/data_overrides/ui.py
+++ b/data_overrides/ui.py
@@ -29,8 +29,8 @@ from data_overrides.override import *
'''
def id_data_children(id_data):
if isinstance(id_data, bpy.types.Object):
- if id_data.dupli_type == 'GROUP' and id_data.dupli_group:
- yield id_data.dupli_group
+ if id_data.instance_type == 'COLLECTION' and id_data.instance_collection:
+ yield id_data.instance_collection
elif isinstance(id_data, bpy.types.Group):
for ob in id_data.objects:
yield ob
diff --git a/io_atomblend_utilities/io_atomblend_utilities.py b/io_atomblend_utilities/io_atomblend_utilities.py
index ef77962f..9562a7c6 100644
--- a/io_atomblend_utilities/io_atomblend_utilities.py
+++ b/io_atomblend_utilities/io_atomblend_utilities.py
@@ -419,7 +419,7 @@ def separate_atoms(scn):
atom = bpy.context.edit_object
# Do nothing if
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list