Commit 8f8e7125 authored by NBurn's avatar NBurn

addons-contrib: objects.link/unlink syntax update

Change objects.link and objects.unlink from scene to collection
parent 00e91ffa
......@@ -52,7 +52,7 @@ def addText(string = '', loc = ((0, 0, 0)), textsize = 1, align = 'CENTER', offs
fnt = bpy.data.fonts.load(font)
tcu.font = fnt
text.location = loc
bpy.context.scene.objects.link(text)
bpy.context.collection.objects.link(text)
return text
......@@ -1514,7 +1514,6 @@ def createCurve(vertArray, self, align_matrix):
name = self.Dimension_Type # Type as name
# create curve
scene = bpy.context.scene
newCurve = bpy.data.curves.new(name, type = 'CURVE') # curvedatablock
newSpline = newCurve.splines.new('BEZIER') # spline
......@@ -1528,7 +1527,7 @@ def createCurve(vertArray, self, align_matrix):
# create object with newCurve
DimensionCurve = bpy.data.objects.new(name, newCurve) # object
scene.objects.link(DimensionCurve) # place in active scene
bpy.context.collection.objects.link(DimensionCurve) # place in active scene
DimensionCurve.Dimension = True
DimensionCurve.matrix_world = align_matrix # apply matrix
self.Dimension_Name = DimensionCurve.name
......
......@@ -344,7 +344,7 @@ def DEF_atom_draw_atoms(prop_element,
atom_mesh.from_pydata(atom_vertices, [], [])
atom_mesh.update()
new_atom_mesh = bpy.data.objects.new(name, atom_mesh)
bpy.context.scene.objects.link(new_atom_mesh)
bpy.context.collection.objects.link(new_atom_mesh)
bpy.ops.surface.primitive_nurbs_surface_sphere_add(
view_align=False, enter_editmode=False,
......
......@@ -320,7 +320,7 @@ def createObjects(tree, parent=None, objectname=None, probability=0.5, size=0.5,
obj.rotation_euler = rot[:]
obj.scale = [scale, scale, scale]
obj.parent = parent
bpy.context.scene.objects.link(obj)
bpy.context.collection.objects.link(obj)
# this is not the best choice of distribution because we might
# get negative values especially if sigma is large
t += gauss(1.0 / probability, 0.1)
......@@ -565,7 +565,7 @@ def createGeometry(tree, power=0.5, scale=0.01, addleaves=False, pleaf=0.5,
# create the tree object an make it the only selected and active object in the scene
obj_new = bpy.data.objects.new(mesh.name, mesh)
base = bpy.context.scene.objects.link(obj_new)
base = bpy.context.collection.objects.link(obj_new)
for ob in bpy.context.scene.objects:
ob.select_set(False)
base.select_set(True)
......@@ -611,7 +611,7 @@ def createGeometry(tree, power=0.5, scale=0.01, addleaves=False, pleaf=0.5,
bleaf, connectoffset
)
obj_leaves = bpy.data.objects.new(mesh.name, mesh)
base = bpy.context.scene.objects.link(obj_leaves)
base = bpy.context.collection.objects.link(obj_leaves)
obj_leaves.parent = obj_new
bpy.context.view_layer.objects.active = obj_leaves
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
......@@ -975,7 +975,7 @@ class SCATree(bpy.types.Operator):
if self.showMarkers:
mesh = createMarkers(sca, self.markerScale)
obj_markers = bpy.data.objects.new(mesh.name, mesh)
base = bpy.context.scene.objects.link(obj_markers)
base = bpy.context.collection.objects.link(obj_markers)
timings.add('showmarkers')
sca.iterate2(newendpointsper1000=self.newEndPointsPer1000, maxtime=self.maxTime)
......
......@@ -60,7 +60,7 @@ class CODuplicateCamera(Operator):
cam_obj = active_cam.copy()
cam_obj.data = active_cam.data.copy()
cam_obj.name = "Camera_Overscan"
context.scene.objects.link(cam_obj)
context.collection.objects.link(cam_obj)
except:
self.report({'WARNING'}, "Setting up a new Overscan Camera has failed")
return {'CANCELLED'}
......
......@@ -119,7 +119,7 @@ class LoftedSurface:
meshObject = bpy.data.objects.new(self.name, mesh)
bpy.context.scene.objects.link(meshObject)
bpy.context.collection.objects.link(meshObject)
......@@ -267,7 +267,7 @@ class SweptSurface:
meshObject = bpy.data.objects.new(self.name, mesh)
bpy.context.scene.objects.link(meshObject)
bpy.context.collection.objects.link(meshObject)
......@@ -456,4 +456,4 @@ class BirailedSurface:
meshObject = bpy.data.objects.new(self.name, mesh)
bpy.context.scene.objects.link(meshObject)
bpy.context.collection.objects.link(meshObject)
......@@ -19,7 +19,6 @@ class OperatorAutoLoftCurves(Operator):
def execute(self, context):
#print("### TODO: OperatorLoftCurves.execute()")
scene = context.scene
mesh = bpy.data.meshes.new("LoftMesh")
curve0 = context.selected_objects[0]
......@@ -31,7 +30,7 @@ class OperatorAutoLoftCurves(Operator):
loftobj = bpy.data.objects.new(self.name, mesh)
scene.objects.link(loftobj)
context.collection.objects.link(loftobj)
loftobj["autoloft"] = True
if loftobj.get('_RNA_UI') is None:
loftobj['_RNA_UI'] = {}
......
......@@ -656,7 +656,7 @@ def draw_obj_special(atom_shape, atom):
new_mesh.from_pydata([Vector((0.0,0.0,0.0))], [], [])
new_mesh.update()
new_atom = bpy.data.objects.new(atom.name + "_sep", new_mesh)
bpy.context.scene.objects.link(new_atom)
bpy.context.collection.objects.link(new_atom)
new_atom.location = atom.location
material_new = bpy.data.materials.new(atom.active_material.name + "_sep")
material_new.name = atom.name + "_halo"
......@@ -698,7 +698,7 @@ def draw_obj_special(atom_shape, atom):
lamp = bpy.data.objects.new("F2+_lamp", lamp_data)
lamp.location = Vector((0.0, 0.0, 0.0))
lamp.layers = current_layers
bpy.context.scene.objects.link(lamp)
bpy.context.collection.objects.link(lamp)
lamp.parent = cube
# The new 'atom' is the F2+ defect
new_atom = cube
......@@ -755,7 +755,7 @@ def draw_obj_special(atom_shape, atom):
lamp = bpy.data.objects.new("F+_lamp", lamp_data)
lamp.location = Vector((0.0, 0.0, 0.0))
lamp.layers = current_layers
bpy.context.scene.objects.link(lamp)
bpy.context.collection.objects.link(lamp)
lamp.parent = cube
# The new 'atom' is the F+ defect complex + lamp
new_atom = cube
......@@ -823,7 +823,7 @@ def draw_obj_special(atom_shape, atom):
lamp1 = bpy.data.objects.new("F0_lamp", lamp1_data)
lamp1.location = Vector((scale[0]*1.5, 0.0, 0.0))
lamp1.layers = current_layers
bpy.context.scene.objects.link(lamp1)
bpy.context.collection.objects.link(lamp1)
lamp1.parent = cube
lamp2_data = bpy.data.lamps.new(name="F0_lamp2", type="POINT")
lamp2_data.distance = atom.scale[0] * 2.0
......@@ -833,7 +833,7 @@ def draw_obj_special(atom_shape, atom):
lamp2 = bpy.data.objects.new("F0_lamp", lamp2_data)
lamp2.location = Vector((-scale[0]*1.5, 0.0, 0.0))
lamp2.layers = current_layers
bpy.context.scene.objects.link(lamp2)
bpy.context.collection.objects.link(lamp2)
lamp2.parent = cube
# The new 'atom' is the F0 defect complex + lamps
new_atom = cube
......
......@@ -144,7 +144,7 @@ def write(obname,name,
# scene link check
if obj.name not in bpy.context.scene.objects.keys() :
bpy.context.scene.objects.link(obj)
bpy.context.collection.objects.link(obj)
return obj
......
......@@ -12,14 +12,14 @@ def new(name,datatype,naming_method):
ob = bpy.data.objects.new(name,datatype)
ob.name = name
elif naming_method == 3 :
bpy.context.scene.objects.unlink(ob)
bpy.context.collection.objects.unlink(ob)
ob.user_clear()
bpy.data.objects.remove(ob)
ob = bpy.data.objects.new(name,datatype)
else :
ob = bpy.data.objects.new(name,datatype)
if ob.name not in bpy.context.scene.objects.keys() :
bpy.context.scene.objects.link(ob)
bpy.context.collection.objects.link(ob)
return ob
## returns an object or a list of objects
......
......@@ -591,7 +591,7 @@ BINARY FORMAT
armname = armdata
armdata = bpy.data.armatures.new(name=armname)
arm = bpy.data.objects.new(armname,armdata)
bpy.context.scene.objects.link(arm)
bpy.context.collection.objects.link(arm)
arm.select_set(True)
bpy.context.view_layer.objects.active = arm
bpy.ops.object.mode_set(mode='EDIT')
......
......@@ -440,10 +440,8 @@ class Import(bpy.types.Operator):
mesh.update()
ob_new = bpy.data.objects.new(TARGET_NAME, mesh)
ob_new.data = mesh
scene = bpy.context.scene
view_layer = bpy.context.view_layer
scene.objects.link(ob_new)
view_layer.objects.active = ob_new
bpy.context.collection.objects.link(ob_new)
bpy.context.view_layer.objects.active = ob_new
ob_new.select_set(True)
print ('*** End draw ***')
print('*** Start Smooth ***')
......
......@@ -58,6 +58,7 @@ def voodoo_import(infile,ld_cam,ld_points):
file = open(infile,'rU')
scene = bpy.context.scene
collection = bpy.context.collection
initfr = scene.frame_current
b24= True
voodoo_import.frwas= False
......@@ -66,7 +67,7 @@ def voodoo_import(infile,ld_cam,ld_points):
dummy.location = (0.0, 0.0, 0.0)
dummy.rotation_euler = ( -3.141593/2, 0.0, 0.0)
dummy.scale = (0.2, 0.2, 0.2)
scene.objects.link(dummy)
collection.objects.link(dummy)
if ld_cam:
data = bpy.data.cameras.new('voodoo_render_cam')
......@@ -82,7 +83,7 @@ def voodoo_import(infile,ld_cam,ld_points):
data.clip_start = 0.1
data.clip_end = 1000.0
data.display_size = 0.5
scene.objects.link(vcam)
collection.objects.link(vcam)
vcam.parent = dummy
if ld_points:
......@@ -94,7 +95,7 @@ def voodoo_import(infile,ld_cam,ld_points):
# mesh.scale = (5.0, 5.0, 5.0)
mesh.rotation_euler = (0.0, 0.0, 0.0)
mesh.scale = (1.0, 1.0, 1.0)
scene.objects.link(mesh)
collection.objects.link(mesh)
mesh.parent = dummy
verts = []
......
......@@ -205,7 +205,7 @@ def create_mesh(data_list,
surface_mesh.from_pydata(data_mesh, [], data_faces)
surface_mesh.update()
surface = bpy.data.objects.new(image_name, surface_mesh)
bpy.context.scene.objects.link(surface)
bpy.context.collection.objects.link(surface)
bpy.ops.object.select_all(action='DESELECT')
surface.select = True
......@@ -252,7 +252,7 @@ def create_mesh(data_list,
camera = bpy.data.objects.new("A_camera", camera_data)
camera.location = camera_xyz_vec
camera.layers = current_layers
bpy.context.scene.objects.link(camera)
bpy.context.collection.objects.link(camera)
# Here the camera is rotated such it looks towards the center of
# the object. The [0.0, 0.0, 1.0] vector along the z axis
......@@ -303,7 +303,7 @@ def create_mesh(data_list,
lamp = bpy.data.objects.new("A_lamp", lamp_data)
lamp.location = lamp_xyz_vec
lamp.layers = current_layers
bpy.context.scene.objects.link(lamp)
bpy.context.collection.objects.link(lamp)
bpy.context.scene.world.light_settings.use_ambient_occlusion = True
bpy.context.scene.world.light_settings.ao_factor = 0.1
......@@ -528,7 +528,7 @@ def import_xyz(Ball_type,
camera = bpy.data.objects.new("A_camera", camera_data)
camera.location = camera_xyz_vec
camera.layers = current_layers
bpy.context.scene.objects.link(camera)
bpy.context.collection.objects.link(camera)
# Here the camera is rotated such it looks towards the center of
# the object. The [0.0, 0.0, 1.0] vector along the z axis
......@@ -579,7 +579,7 @@ def import_xyz(Ball_type,
lamp = bpy.data.objects.new("A_lamp", lamp_data)
lamp.location = lamp_xyz_vec
lamp.layers = current_layers
bpy.context.scene.objects.link(lamp)
bpy.context.collection.objects.link(lamp)
bpy.context.scene.world.light_settings.use_ambient_occlusion = True
bpy.context.scene.world.light_settings.ao_factor = 0.2
......@@ -607,7 +607,7 @@ def import_xyz(Ball_type,
atom_mesh.from_pydata(atom_vertices, [], [])
atom_mesh.update()
new_atom_mesh = bpy.data.objects.new(atom.name, atom_mesh)
bpy.context.scene.objects.link(new_atom_mesh)
bpy.context.collection.objects.link(new_atom_mesh)
# Now, build a representative sphere (atom)
current_layers=bpy.context.scene.layers
......
......@@ -38,10 +38,8 @@ def create_and_link_mesh(name, points):
mesh.validate()
mesh.update()
scene = bpy.context.scene
obj = bpy.data.objects.new(name, mesh)
scene.objects.link(obj)
bpy.context.collection.objects.link(obj)
obj.select_set(True)
......
......@@ -268,7 +268,7 @@ def load(self, context, filepath=""):
me.from_pydata(vert_table, [], face_table)
me.update()
ob = bpy.data.objects.new("Py-Mesh", me)
bpy.context.scene.objects.link(ob)
bpy.context.collection.objects.link(ob)
state = 31
......
......@@ -661,6 +661,7 @@ class FptImporter():
self.__context = blender_context
self.__data = blender_context.blend_data
self.__scene = blender_context.scene
self.__collection = blender_context.collection
self.__view_layer = blender_context.view_layer
try:
......@@ -830,7 +831,7 @@ class FptImporter():
blender_empty_object.rotation_euler = blender_rotation
blender_empty_object.empty_display_type = 'ARROWS'
blender_empty_object.empty_display_size = 10.0
self.__scene.objects.link(blender_empty_object)
self.__collection.objects.link(blender_empty_object)
blender_empty_object.layers = layers
blender_empty_object.fpt.name = fpx_item_name
......@@ -977,7 +978,7 @@ class FptImporter():
name = "Camera.table"
camera = self.__data.cameras.new(name)
obj = self.__data.objects.new(name, camera)
self.__scene.objects.link(obj)
self.__collection.objects.link(obj)
width = fpx_table_data.get_value("width", default=0.0)
obj.location = (width / 2.0, -1600.0, 550.0)
obj.rotation_euler = (radians(63.0), 0.0, 0.0)
......@@ -1036,14 +1037,14 @@ class FptImporter():
self.__scene.render.engine = tmp_engine
obj = self.__data.objects.new(FORMAT_LAMP_OBJECT.format(name), lamp)
self.__scene.objects.link(obj)
self.__collection.objects.link(obj)
obj.location = (width2, -length * (2.0/3.0), 600.0)
obj.layers = FptImporter.LAYERS_AO
# cycles
mesh = self.__data.meshes.new(FORMAT_MESH.format("{}.arealamp".format(name)))
obj = self.__data.objects.new(FORMAT_MESH_OBJECT.format(name), mesh)
self.__scene.objects.link(obj)
self.__collection.objects.link(obj)
obj.location = (width2, -length * (2.0/3.0), 610.0)
obj.layers = FptImporter.LAYERS_AO
bm = bmesh.new()
......@@ -1080,7 +1081,7 @@ class FptImporter():
self.__scene.render.engine = tmp_engine
obj = self.__data.objects.new(FORMAT_LAMP_OBJECT.format(name), lamp)
self.__scene.objects.link(obj)
self.__collection.objects.link(obj)
obj.location = location
obj.layers = layers
......@@ -1489,7 +1490,7 @@ class FptImporter():
mesh = self.__data.meshes.new(FORMAT_MESH.format(name))
obj = self.__data.objects.new(FORMAT_MESH_OBJECT.format(name), mesh)
self.__scene.objects.link(obj)
self.__collection.objects.link(obj)
obj.layers = FptImporter.LAYERS_AO
#inner playfield
......@@ -1525,7 +1526,7 @@ class FptImporter():
mesh_box = self.__data.meshes.new(FORMAT_MESH.format("{}.playfield".format(name)))
obj_box = self.__data.objects.new(FORMAT_MESH_OBJECT.format("{}.playfield".format(name)), mesh_box)
obj_box.parent = obj
self.__scene.objects.link(obj_box)
self.__collection.objects.link(obj_box)
obj_box.layers = FptImporter.LAYERS_AO
bm = bmesh.new()
......@@ -1584,7 +1585,7 @@ class FptImporter():
mesh_translite = self.__data.meshes.new(FORMAT_MESH.format("{}.translite".format(name)))
obj_translite = self.__data.objects.new(FORMAT_MESH_OBJECT.format("{}.translite".format(name)), mesh_translite)
obj_translite.parent = obj
self.__scene.objects.link(obj_translite)
self.__collection.objects.link(obj_translite)
obj_translite.layers = FptImporter.LAYERS_AO
#inner translite
......@@ -1693,7 +1694,7 @@ class FptImporter():
if rubber_bevel is None:
cu0 = self.__data.curves.new(bevel_name, 'CURVE')
rubber_bevel = self.__data.objects.new(bevel_name, cu0)
self.__scene.objects.link(rubber_bevel)
self.__collection.objects.link(rubber_bevel)
cu0.dimensions = '2D'
cu0.resolution_u = self.resolution_rubber_bevel
......@@ -1949,7 +1950,7 @@ class FptImporter():
mesh = self.__data.meshes.new(FORMAT_MESH.format(name))
obj = self.__data.objects.new(FORMAT_MESH_OBJECT.format(name), mesh)
self.__scene.objects.link(obj)
self.__collection.objects.link(obj)
z = surface + self.debug_light_extrude
bm = bmesh.new()
......@@ -2022,7 +2023,7 @@ class FptImporter():
blender_empty_object.rotation_euler = Euler((0, 0, Vector((v.x, v.y)).angle_signed(Vector((1.0, 0.0)))), 'XZY')
blender_empty_object.empty_display_type = 'ARROWS'
blender_empty_object.empty_display_size = 10.0
self.__scene.objects.link(blender_empty_object)
self.__collection.objects.link(blender_empty_object)
blender_empty_object.fpt.name = FORMAT_EMPTY_OBJECT.format(FORMAT_MODEL_START.format(name))
if fpx_id:
blender_empty_object.fpt.id = FptElementType.VALUE_INT_TO_NAME.get(fpx_id)
......@@ -2039,7 +2040,7 @@ class FptImporter():
blender_empty_object.rotation_euler = Euler((0, 0, Vector((v.x, v.y)).angle_signed(Vector((1.0, 0.0)))), 'XZY')
blender_empty_object.empty_display_type = 'ARROWS'
blender_empty_object.empty_display_size = 10.0
self.__scene.objects.link(blender_empty_object)
self.__collection.objects.link(blender_empty_object)
blender_empty_object.fpt.name = FORMAT_EMPTY_OBJECT.format(FORMAT_MODEL_END.format(name))
if fpx_id:
blender_empty_object.fpt.id = FptElementType.VALUE_INT_TO_NAME.get(fpx_id)
......@@ -2137,7 +2138,7 @@ class FptImporter():
blender_empty_object.rotation_euler = Euler((0, 0, Vector((v.x, v.y)).angle_signed(Vector((1.0, 0.0)))), 'XZY')
blender_empty_object.empty_display_type = 'ARROWS'
blender_empty_object.empty_display_size = 10.0
self.__scene.objects.link(blender_empty_object)
self.__collection.objects.link(blender_empty_object)
blender_empty_object.fpt.name = FORMAT_MODEL_RING.format(name, index)
if fpx_id:
blender_empty_object.fpt.id = FptElementType.VALUE_INT_TO_NAME.get(fpx_id)
......@@ -2219,7 +2220,7 @@ class FptImporter():
if wire_bevel is None:
cu = self.__data.curves.new(bevel_name, 'CURVE')
wire_bevel = self.__data.objects.new(bevel_name, cu)
self.__scene.objects.link(wire_bevel)
self.__collection.objects.link(wire_bevel)
cu.dimensions = '2D'
cu.resolution_u = self.resolution_shape
......@@ -2332,7 +2333,7 @@ class FptImporter():
def create_curve(self, name, layers, curve_resolution):
cu = self.__data.curves.new(FORMAT_CURVE.format(name), 'CURVE')
obj = self.__data.objects.new(FORMAT_CURVE_OBJECT.format(name), cu)
self.__scene.objects.link(obj)
self.__collection.objects.link(obj)
cu.dimensions = '3D'
cu.twist_mode = 'Z_UP'
......@@ -2505,7 +2506,7 @@ class FptImporter():
cu = self.__data.curves.new("{}.bevel_curve".format(name), 'CURVE')
obj = self.__data.objects.new("{}".format(name), cu)
self.__scene.objects.link(obj)
self.__collection.objects.link(obj)
cu.dimensions = '2D'
cu.twist_mode = 'Z_UP'
......@@ -2558,7 +2559,7 @@ class FptImporter():
if wire_bevel is None:
cu = self.__data.curves.new(bevel_name, 'CURVE')
wire_bevel = self.__data.objects.new(bevel_name, cu)
self.__scene.objects.link(wire_bevel)
self.__collection.objects.link(wire_bevel)
cu.dimensions = '2D'
cu.resolution_u = self.resolution_wire_bevel
......@@ -2582,7 +2583,7 @@ class FptImporter():
if wire_bevel is None:
cu = self.__data.curves.new(bevel_name, 'CURVE')
wire_bevel = self.__data.objects.new(bevel_name, cu)
self.__scene.objects.link(wire_bevel)
self.__collection.objects.link(wire_bevel)
cu.dimensions = '2D'
cu.resolution_u = self.resolution_wire_bevel
......@@ -2633,7 +2634,7 @@ class FptImporter():
blender_empty_object_new.rotation_euler = Euler((0, 0, radians(angle)), blender_empty_object.rotation_mode)
blender_empty_object_new.empty_display_type = blender_empty_object.empty_display_type
blender_empty_object_new.empty_display_size = blender_empty_object.empty_display_size
self.__scene.objects.link(blender_empty_object_new)
self.__collection.objects.link(blender_empty_object_new)
old_group_dict = {}
for old_vert in old_mesh.vertices:
......
......@@ -477,6 +477,7 @@ def export_map(context, filepath):
print("Map Exporter 0.0")
scene = context.scene
collection = context.collection
objects = context.selected_objects
obs_mesh = []
......@@ -657,7 +658,7 @@ def export_map(context, filepath):
print("\t\tignoring %s" % ob.name)
for ob in obs_mesh:
scene.objects.unlink(ob)
collection.objects.unlink(ob)
bpy.data.objects.remove(ob)
print("Exported Map in %.4fsec" % (time.time() - t))
......
......@@ -238,10 +238,8 @@ def read(context, filepath, scale=100.0, tag=False, utm=False):
me.transform(global_matrix)
# create the object in the scene
scene = context.scene
view_layer = context.view_layer
scene.objects.link(obj)
view_layer.objects.active = obj
context.collection.objects.link(obj)
context.view_layer.objects.active = obj
obj.select_set(True)
# entry points for other addons
......
......@@ -269,8 +269,9 @@ def do_creaprim(self, mesh, objname, addondir):
strlist.append("\n")
strlist.append(" mesh = bpy.data.meshes.new(name=\"" + objname + "\")\n")
strlist.append(" obj = bpy.data.objects.new(name=\"" + objname + "\", object_data=mesh)\n")
strlist.append(" collection = bpy.context.collection\n")
strlist.append(" scene = bpy.context.scene\n")
strlist.append(" scene.objects.link(obj)\n")
strlist.append(" collection.objects.link(obj)\n")
strlist.append(" obj.location = scene.cursor_location\n")
strlist.append(" bm = bmesh.new()\n")
strlist.append(" bm.from_mesh(mesh)\n")
......
......@@ -61,7 +61,7 @@ def object_osc_futurism (self, context,STEP, HOLD):
# CREO OBJETO
OBJECT=bpy.data.objects.new(ACTOBJ.name[:3]+str(FC), MESH)
# CONECTO A LA ESCENA
bpy.context.scene.objects.link(OBJECT)
bpy.context.collection.objects.link(OBJECT)
# SETEO FRAME CURRENT
bpy.context.scene.frame_set(FC)
# MARCO EXPRESIONES PARA VIEW
......
......@@ -312,9 +312,9 @@ def OscLinkedGroupToLocal():
GROBJS = [ob for ob in ACTOBJ.id_data.instance_collection.objects[:] if ob.type == "MESH"]
for ob in ACTOBJ.id_data.instance_collection.objects[:]:
bpy.context.scene.objects.link(ob)
bpy.context.collection.objects.link(ob)
NEWGROUP = bpy.data.collections.new("%s_CLEAN" % (ACTOBJ.name))
bpy.context.scene.objects.unlink(ACTOBJ)
bpy.context.collection.objects.unlink(ACTOBJ)
NEWOBJ = []
for ob in GROBJS:
NEWGROUP.objects.link(ob)
......
......@@ -37,7 +37,7 @@ def func_osc_screw(self, STRETCH,TURNS,DIAMETER,RESOLUTION):
# DATA PARA EL MESH
me = bpy.data.meshes.new("threadData")
obj = bpy.data.objects.new("Thread", me)
bpy.context.scene.objects.link(obj)
bpy.context.collection.objects.link(obj)
# VARIABLES
vertexlist=[]
......
......@@ -148,6 +148,7 @@ class NodeTree:
class View:
def __init__(self, name, euler_rotation):
self._name = name
self._collection = None
self._scene = None
self._scene_camera = None
self._node = None
......@@ -190,7 +191,7 @@ class View:
self._scene_camera = self._scene.camera
self._camera = bpy.data.objects.new(self._name, data)
self._scene.objects.link(self._camera)
self._collection.objects.link(self._camera)
rotation = self._euler_rotation.copy()
rotation.z += zed
......@@ -202,7 +203,7 @@ class View:
self._scene.camera = self._camera
def resetCamera(self):
self._scene.objects.unlink(self._camera)
self._collection.objects.unlink(self._camera)
bpy.data.objects.remove(self._camera)
self._camera = None
......@@ -281,6 +282,8 @@ def cube_map_render_init(scene, use_force=False):
hashes.append(hash(scene))
view.setScene(scene)
# have Dalai to look at this?
view._collection = bpy.context.collection # XXX TODO better fix
# create a scene from scratch
node_tree_data = NodeTree(main_scene)
......
......@@ -225,12 +225,13 @@ class RemoveSurroundCamerasOperator(bpy.types.Operator):
def execute(self, context):
scene = context.scene
collection = context.collection
# XXX. shouldnt there be some less general way to do this?
# like check if they are the child of origin? - campbell