diff --git a/blenderkit/overrides.py b/blenderkit/overrides.py index a0c7632646073adbf1d28a528994fc46939f4dd8..606a19bb5706edf8f0d013c3ddf7d3c905f9e3bf 100644 --- a/blenderkit/overrides.py +++ b/blenderkit/overrides.py @@ -187,18 +187,18 @@ class BringToScene(Operator): return bpy.context.view_layer.objects.active is not None def execute(self, context): - import bpy s = bpy.context.scene sobs = s.collection.all_objects aob = bpy.context.active_object dg = aob.instance_collection - instances = [] + vlayer = bpy.context.view_layer + instances_emptys = [] # first, find instances of this collection in the scene for ob in sobs: - if ob.instance_collection == dg and ob not in instances: - instances.append(ob) + if ob.instance_collection == dg and ob not in instances_emptys: + instances_emptys.append(ob) ob.instance_collection = None ob.instance_type = 'NONE' # dg.make_local @@ -208,21 +208,28 @@ class BringToScene(Operator): dg.objects.unlink(ob) try: s.collection.objects.link(ob) - + ob.select_set(True) + obs.append(ob) if ob.parent == None: parent = ob bpy.context.view_layer.objects.active = parent except Exception as e: print(e) - ob.select_set(True) - obs.append(ob) + bpy.ops.object.make_local(type='ALL') - for ob in obs: - ob.select_set(True) + + for i, ob in enumerate(obs): + if ob.name in vlayer.objects: + obs[i] = vlayer.objects[ob.name] + try: + ob.select_set(True) + except Exception as e: + print('failed to select an object from the collection, getting a replacement.') + print(e) related = [] - for i, ob in enumerate(instances): + for i, ob in enumerate(instances_emptys): if i > 0: bpy.ops.object.duplicate(linked=True) diff --git a/blenderkit/search.py b/blenderkit/search.py index 641b154866ed8968b47d068b1a53632bbf2868b0..8406e47d54581748a530d86c93cf1d39ccf27649 100644 --- a/blenderkit/search.py +++ b/blenderkit/search.py @@ -55,7 +55,7 @@ from bpy.types import ( import requests, os, random import time import threading -import tempfile +import platform import json import bpy @@ -133,19 +133,20 @@ last_clipboard = '' def check_clipboard(): # clipboard monitoring to search assets from web - global last_clipboard - if bpy.context.window_manager.clipboard != last_clipboard: - last_clipboard = bpy.context.window_manager.clipboard - instr = 'asset_base_id:' - # first check if contains asset id, then asset type - if last_clipboard[:len(instr)] == instr: - atstr = 'asset_type:' - ati = last_clipboard.find(atstr) - # this only checks if the asset_type keyword is there but let's the keywords update function do the parsing. - if ati > -1: - search_props = utils.get_search_props() - search_props.search_keywords = last_clipboard - # don't run search after this - assigning to keywords runs the search_update function. + if platform.system() != 'Linux': + global last_clipboard + if bpy.context.window_manager.clipboard != last_clipboard: + last_clipboard = bpy.context.window_manager.clipboard + instr = 'asset_base_id:' + # first check if contains asset id, then asset type + if last_clipboard[:len(instr)] == instr: + atstr = 'asset_type:' + ati = last_clipboard.find(atstr) + # this only checks if the asset_type keyword is there but let's the keywords update function do the parsing. + if ati > -1: + search_props = utils.get_search_props() + search_props.search_keywords = last_clipboard + # don't run search after this - assigning to keywords runs the search_update function. # @bpy.app.handlers.persistent diff --git a/io_export_dxf/export_dxf.py b/io_export_dxf/export_dxf.py index 88a27b3b95a059ee0884d6e3dbe19185e7937f6a..71434a716c88d7a2c030a8fdb8f3d49f88eb0016 100644 --- a/io_export_dxf/export_dxf.py +++ b/io_export_dxf/export_dxf.py @@ -35,7 +35,7 @@ def exportDXF(context, filePath, settings): """ print("----------\nExporting to {}".format(filePath)) import time - time1 = time.clock() + time1 = time.perf_counter() if settings['verbose']: print("Generating Object list for export... (Root parents only)") @@ -71,7 +71,7 @@ def exportDXF(context, filePath, settings): drawing.convert(filePath) - duration = time.clock() - time1 + duration = time.perf_counter() - time1 print('%s objects exported in %.2f seconds. -----DONE-----' %\ (exported, duration)) except IOError: