From 383aa98abe728571218defd571b750c2bb9cc530 Mon Sep 17 00:00:00 2001 From: Brady Johnston Date: Sat, 6 Apr 2024 10:07:02 +0800 Subject: [PATCH] fixed density importing it seems that there is now a blender 4.1 issue where even if the underlying `.vdb` changes, if you reimport the file it still uses the preview for the 'old' version. Because of this, the created .vdb file path now contains whether or not it was centred and inverted, which makes different files and fixes the issues. --- molecularnodes/io/density.py | 14 +- molecularnodes/io/parse/density.py | 4 +- molecularnodes/io/parse/mrc.py | 54 +++-- .../test_random_rgb/color_values.txt | 2 +- .../invert_nodesetup_center_positions.txt | 200 +++++++++--------- .../invert_nodesetup_center_positions.txt | 200 +++++++++--------- .../8U8W-surface/position.txt | 2 +- tests/test_density.py | 19 +- 8 files changed, 259 insertions(+), 236 deletions(-) diff --git a/molecularnodes/io/density.py b/molecularnodes/io/density.py index 3dcefccf..cd471f69 100644 --- a/molecularnodes/io/density.py +++ b/molecularnodes/io/density.py @@ -40,15 +40,19 @@ def load( invert: bool = False, setup_nodes: bool = True, style: str = 'density_surface', - center: bool = False + center: bool = False, + overwrite: bool = False ): - density = parse.MRC(file_path=file_path, center=center, invert=invert) + density = parse.MRC( + file_path=file_path, + center=center, + invert=invert, + overwrite=overwrite + ) density.create_model( name=name, - invert=invert, setup_nodes=setup_nodes, - style=style, - center=center + style=style ) return density diff --git a/molecularnodes/io/parse/density.py b/molecularnodes/io/parse/density.py index 5fd0bec7..bc16cd16 100644 --- a/molecularnodes/io/parse/density.py +++ b/molecularnodes/io/parse/density.py @@ -17,7 +17,7 @@ def __init__(self, file_path): self.threshold: float = None self.object: bpy.types.Object = None - def path_to_vdb(self, file: str): + def path_to_vdb(self, file: str, center: False, invert: False): """ Convert a file path to a corresponding VDB file path. @@ -34,6 +34,8 @@ def path_to_vdb(self, file: str): # Set up file paths folder_path = os.path.dirname(file) name = os.path.basename(file).split(".")[0] + name += "_center" if center else "" + name += "_invert" if invert else "" file_name = name + '.vdb' file_path = os.path.join(folder_path, file_name) return file_path diff --git a/molecularnodes/io/parse/mrc.py b/molecularnodes/io/parse/mrc.py index 384db743..aae97b42 100644 --- a/molecularnodes/io/parse/mrc.py +++ b/molecularnodes/io/parse/mrc.py @@ -14,21 +14,22 @@ class MRC(Density): that can be written as `.vdb` files and the imported into Blender as volumetric objects. """ - def __init__(self, file_path, center=False, invert=False): + def __init__(self, file_path, center=False, invert=False, overwrite=False): super().__init__(self) self.file_path = file_path self.grid = self.map_to_grid(self.file_path, center=center) self.file_vdb = self.map_to_vdb( - self.file_path, center=center, invert=invert) + self.file_path, + center=center, + invert=invert, + overwrite=overwrite + ) def create_model( self, name='NewDensity', style='density_surface', - setup_nodes=True, - invert: bool = False, - center: bool = False, - world_scale: float = 0.01 + setup_nodes=True ) -> bpy.types.Object: """ Loads an MRC file into Blender as a volumetric object. @@ -39,20 +40,16 @@ def create_model( Path to the MRC file. name : str, optional If not None, renames the object with the new name. - invert : bool, optional - Whether to invert the data from the grid, defaulting to False. Some file types - such as EM tomograms have inverted values, where a high value == low density. - world_scale : float, optional - Scale of the object in the world. Defaults to 0.01. - center : bool, optional - Whether to center the volume on the origin. Defaults to False. Returns ------- bpy.types.Object The loaded volumetric object. """ + # import and ensure object is at world origin to get corect alignment with + # structures object = obj.import_vdb(self.file_vdb, collection=coll.mn()) + object.location = (0, 0, 0) self.object = object object.mn['molecule_type'] = 'density' @@ -62,7 +59,10 @@ def create_model( if setup_nodes: nodes.create_starting_nodes_density( - object, style=style, threshold=self.threshold) + object=object, + style=style, + threshold=self.threshold + ) return object @@ -98,7 +98,7 @@ def map_to_vdb( """ import pyopenvdb as vdb - file_path = self.path_to_vdb(file) + file_path = self.path_to_vdb(file, center=center, invert=invert) # If the map has already been converted to a .vdb and overwrite is False, return that instead if os.path.exists(file_path) and not overwrite: @@ -108,18 +108,32 @@ def map_to_vdb( self.threshold = grid['MN_initial_threshold'] return file_path + print("Reading new file") # Read in the MRC file and convert it to a pyopenvdb grid - grid = self.map_to_grid(file, invert=invert, center=center) + grid = self.map_to_grid( + file=file, + invert=invert, + center=center + ) + + grid.transform.scale( + np.array((1, 1, 1)) * world_scale * grid['MN_voxel_size'] + ) - grid.transform.scale(np.array((1, 1, 1)) * - world_scale * grid['MN_voxel_size']) if center: - grid.transform.translate(-np.array(grid['MN_box_size']) - * 0.5 * world_scale * grid['MN_voxel_size']) + offset = -np.array(grid['MN_box_size']) * 0.5 + offset *= grid['MN_voxel_size'] * world_scale + print("transforming") + grid.transform.translate(offset) + + if os.path.exists(file_path): + os.remove(file_path) # Write the grid to a .vdb file + print('writing new file') vdb.write(file_path, grids=[grid]) self.threshold = grid['MN_initial_threshold'] + del grid # Return the path to the output file return file_path diff --git a/tests/snapshots/test_color/test_random_rgb/color_values.txt b/tests/snapshots/test_color/test_random_rgb/color_values.txt index 79a4f98d..a8b492f3 100644 --- a/tests/snapshots/test_color/test_random_rgb/color_values.txt +++ b/tests/snapshots/test_color/test_random_rgb/color_values.txt @@ -1,4 +1,4 @@ -[[0.84 0.36 0.808 1. ] +[[0.725 0.36 0.84 1. ] [0.84 0.747 0.36 1. ] [0.84 0.36 0.487 1. ] [0.635 0.84 0.36 1. ] diff --git a/tests/snapshots/test_density/test_density_operator/False-True-False/invert_nodesetup_center_positions.txt b/tests/snapshots/test_density/test_density_operator/False-True-False/invert_nodesetup_center_positions.txt index d675d520..ee6f1ef7 100644 --- a/tests/snapshots/test_density/test_density_operator/False-True-False/invert_nodesetup_center_positions.txt +++ b/tests/snapshots/test_density/test_density_operator/False-True-False/invert_nodesetup_center_positions.txt @@ -1,100 +1,100 @@ -[[ 1.198 -1.013 0.382] - [-1.062 1.198 0.813] - [ 1.004 -0.996 1.198] - [-1.198 0.141 -0.456] - [-0.888 -0.689 1.198] - [ 1.198 -1.004 -0.656] - [-0.083 -1.198 -0.025] - [-1.198 -1.013 0.141] - [-1.195 -1.195 0.764] - [-1.198 1.038 -0.166] - [ 0.365 0.456 1.198] - [-0.614 1.198 0.282] - [ 1.054 0.83 -1.198] - [ 1.198 -1.096 -0.921] - [ 0.697 1.198 0.307] - [-0.365 0.091 -1.198] - [-1.129 -0.515 -1.198] - [ 1.198 -0.747 -0.573] - [-1.198 -0.506 -0.498] - [ 0.232 -1.198 0.697] - [-0.739 -0.789 1.198] - [ 1.198 -0.73 0.78 ] - [-0.963 -1.198 0.473] - [ 0.498 1.198 0.747] - [ 1.198 0.091 0.008] - [ 0.739 -1.046 -1.198] - [ 1.198 0.639 1.179] - [-0.133 0.647 1.198] - [-1.145 1.198 -0.946] - [-0.058 1.198 -0.772] - [-1.198 0.656 -0.523] - [-1.162 -1.198 0.888] - [-0.349 1.198 -0.556] - [-0.697 1.198 -0.589] - [ 0.548 1.198 -0.838] - [ 1.198 -0.647 0.465] - [ 0.515 1.198 0.257] - [ 0.05 -1.198 -0.058] - [ 0.349 0.481 1.198] - [ 1.198 -0.672 0.515] - [-0.539 0.963 1.198] - [ 0.124 1.198 -0.946] - [-1.198 0.456 -0.647] - [ 1.198 0.141 -0.44 ] - [ 0.041 0.531 -1.198] - [-0.623 -0.158 -1.198] - [-1.198 0.664 -1.087] - [-0.78 0.473 -1.198] - [ 1.198 -0.755 -0.083] - [ 0.656 -1.187 -1.198] - [ 1.198 -0.631 0.241] - [ 0.564 -1.198 -0.739] - [ 0.78 -0.041 -1.198] - [ 0.598 1.198 -0.813] - [-1.198 0.614 -0.672] - [ 0.805 1.087 1.198] - [-0.946 -1.198 -0.058] - [ 0.548 1.198 -0.158] - [ 0.473 -0.896 1.198] - [ 1.198 -0.872 -0.066] - [ 0.921 -1.198 0.133] - [-1.198 0.739 -0.73 ] - [-1.198 -0.78 0.788] - [-0.548 1.198 0.398] - [ 1.071 0.598 1.198] - [-0.855 -1.198 -0.108] - [ 1.195 -0.971 1.195] - [ 0.116 0.664 1.198] - [ 1.198 0.88 1.096] - [-0.813 0.581 -1.198] - [-0.847 -0.797 1.198] - [ 1.112 1.198 0.083] - [ 1.198 -0.407 1.179] - [ 1.198 0.581 0.938] - [-1.096 -1.198 0.249] - [-0.979 0.573 1.198] - [-1.004 1.198 0.896] - [ 0.813 -0.988 1.198] - [ 0.531 1.198 -0.681] - [ 1.198 0.755 0.224] - [ 1.198 -0.639 0.664] - [-0.232 -1.179 1.198] - [ 1.062 1.198 -0.49 ] - [-1.198 -0.274 -0.158] - [ 0.423 -0.656 1.198] - [-0.73 0.008 -1.198] - [ 0.382 -1.198 -0.639] - [-1.145 1.198 0.963] - [ 0.232 0.066 -1.198] - [ 1.038 -1.198 -0.191] - [-0.913 0.008 -1.198] - [-0.556 1.198 0.689] - [-1.198 0.44 0.598] - [-1.198 0.515 -0.813] - [-0.365 -0.946 1.198] - [ 1.198 0.357 -0.116] - [ 0.93 0.481 1.198] - [-0.581 -0.058 1.198] - [-0.88 -1.198 -0.008] - [-1.198 0.34 0.141]] \ No newline at end of file +[[1.195 1.529 1.23 ] + [0.888 0.963 1.462] + [1.221 1.511 0.953] + [1.317 0.705 0.993] + [0.793 0.865 1.295] + [0.901 0.8 0.959] + [1.029 0.883 1.141] + [1.324 1.278 1.383] + [1.193 1.857 1.227] + [1.161 1.577 0.949] + [1.345 1.841 1.301] + [1.163 0.938 1.388] + [1.121 0.855 1.212] + [1.057 0.692 1.038] + [1.275 0.876 0.983] + [1.211 1.618 1.029] + [1.06 1.582 1.115] + [1.391 1.544 1.425] + [1.234 1.016 1.415] + [1.095 1.445 1.093] + [1.106 1.442 1.176] + [1.287 1.61 1.31 ] + [0.967 0.743 1.1 ] + [1.033 1.216 1.275] + [1.189 1.308 1.215] + [1.188 1.195 1.104] + [1.321 2.055 1.283] + [1.382 1.557 1.349] + [1.27 0.863 0.846] + [1.27 1.356 1.087] + [1.226 1.404 1.126] + [1.303 1.745 1.145] + [0.939 0.631 1.145] + [1.274 0.884 1.283] + [1.112 0.985 1.419] + [0.988 0.728 1.293] + [1.179 0.914 1.136] + [1.236 1.02 1.096] + [1.264 0.919 0.791] + [1.358 1.013 1.074] + [1.27 2.09 1.198] + [0.946 0.766 1.085] + [1.506 1.474 1.149] + [1.066 1.499 1.15 ] + [1.383 1.067 1.09 ] + [1.254 1.848 1.245] + [1.332 0.926 1.017] + [0.963 0.765 1.27 ] + [0.833 0.838 1.259] + [1.185 1.964 1.177] + [1.116 0.595 0.868] + [1.278 1.261 1.262] + [1.171 0.853 1.486] + [1.22 1.565 0.917] + [1.009 1.216 1.456] + [1.361 1.502 1.061] + [1.178 1.542 1.195] + [1.241 2.087 1.166] + [1.3 2.005 1.099] + [1.272 1.561 0.97 ] + [1.018 0.811 0.971] + [1.223 1.801 1.193] + [1.195 0.896 1.113] + [1.253 0.741 0.941] + [1.204 1.296 1.071] + [1.311 0.996 1.161] + [1.079 0.606 1.139] + [1.179 0.84 1.286] + [1.179 2.006 1.184] + [0.999 1.032 1.298] + [0.963 0.631 1.228] + [1.283 1.44 1.067] + [1.269 1.569 1.387] + [1.077 1.162 1.171] + [1.04 1.555 1.248] + [0.968 0.954 1.447] + [1.215 1.336 1.237] + [1.323 1.278 1.383] + [1.294 0.857 0.938] + [1.077 0.755 1.243] + [1.374 1.407 1.283] + [1.052 1.437 1.163] + [1.133 1.042 1.455] + [1.212 1.45 1.063] + [1.136 0.681 0.865] + [1.053 0.764 1.426] + [1.206 1.253 1.114] + [1.104 0.777 0.849] + [1.278 2.03 1.184] + [1.076 1.116 1.354] + [0.95 0.911 0.93 ] + [1.055 1.137 1.137] + [0.932 1.177 1.155] + [1.048 0.647 0.913] + [1.331 1.071 1.326] + [1.099 0.984 1.286] + [1.145 1.253 1.159] + [1.275 1.472 1.148] + [1.224 1.547 1.299] + [1.237 1.573 1.158]] \ No newline at end of file diff --git a/tests/snapshots/test_density/test_density_operator/False-True-True/invert_nodesetup_center_positions.txt b/tests/snapshots/test_density/test_density_operator/False-True-True/invert_nodesetup_center_positions.txt index d675d520..108fb01b 100644 --- a/tests/snapshots/test_density/test_density_operator/False-True-True/invert_nodesetup_center_positions.txt +++ b/tests/snapshots/test_density/test_density_operator/False-True-True/invert_nodesetup_center_positions.txt @@ -1,100 +1,100 @@ -[[ 1.198 -1.013 0.382] - [-1.062 1.198 0.813] - [ 1.004 -0.996 1.198] - [-1.198 0.141 -0.456] - [-0.888 -0.689 1.198] - [ 1.198 -1.004 -0.656] - [-0.083 -1.198 -0.025] - [-1.198 -1.013 0.141] - [-1.195 -1.195 0.764] - [-1.198 1.038 -0.166] - [ 0.365 0.456 1.198] - [-0.614 1.198 0.282] - [ 1.054 0.83 -1.198] - [ 1.198 -1.096 -0.921] - [ 0.697 1.198 0.307] - [-0.365 0.091 -1.198] - [-1.129 -0.515 -1.198] - [ 1.198 -0.747 -0.573] - [-1.198 -0.506 -0.498] - [ 0.232 -1.198 0.697] - [-0.739 -0.789 1.198] - [ 1.198 -0.73 0.78 ] - [-0.963 -1.198 0.473] - [ 0.498 1.198 0.747] - [ 1.198 0.091 0.008] - [ 0.739 -1.046 -1.198] - [ 1.198 0.639 1.179] - [-0.133 0.647 1.198] - [-1.145 1.198 -0.946] - [-0.058 1.198 -0.772] - [-1.198 0.656 -0.523] - [-1.162 -1.198 0.888] - [-0.349 1.198 -0.556] - [-0.697 1.198 -0.589] - [ 0.548 1.198 -0.838] - [ 1.198 -0.647 0.465] - [ 0.515 1.198 0.257] - [ 0.05 -1.198 -0.058] - [ 0.349 0.481 1.198] - [ 1.198 -0.672 0.515] - [-0.539 0.963 1.198] - [ 0.124 1.198 -0.946] - [-1.198 0.456 -0.647] - [ 1.198 0.141 -0.44 ] - [ 0.041 0.531 -1.198] - [-0.623 -0.158 -1.198] - [-1.198 0.664 -1.087] - [-0.78 0.473 -1.198] - [ 1.198 -0.755 -0.083] - [ 0.656 -1.187 -1.198] - [ 1.198 -0.631 0.241] - [ 0.564 -1.198 -0.739] - [ 0.78 -0.041 -1.198] - [ 0.598 1.198 -0.813] - [-1.198 0.614 -0.672] - [ 0.805 1.087 1.198] - [-0.946 -1.198 -0.058] - [ 0.548 1.198 -0.158] - [ 0.473 -0.896 1.198] - [ 1.198 -0.872 -0.066] - [ 0.921 -1.198 0.133] - [-1.198 0.739 -0.73 ] - [-1.198 -0.78 0.788] - [-0.548 1.198 0.398] - [ 1.071 0.598 1.198] - [-0.855 -1.198 -0.108] - [ 1.195 -0.971 1.195] - [ 0.116 0.664 1.198] - [ 1.198 0.88 1.096] - [-0.813 0.581 -1.198] - [-0.847 -0.797 1.198] - [ 1.112 1.198 0.083] - [ 1.198 -0.407 1.179] - [ 1.198 0.581 0.938] - [-1.096 -1.198 0.249] - [-0.979 0.573 1.198] - [-1.004 1.198 0.896] - [ 0.813 -0.988 1.198] - [ 0.531 1.198 -0.681] - [ 1.198 0.755 0.224] - [ 1.198 -0.639 0.664] - [-0.232 -1.179 1.198] - [ 1.062 1.198 -0.49 ] - [-1.198 -0.274 -0.158] - [ 0.423 -0.656 1.198] - [-0.73 0.008 -1.198] - [ 0.382 -1.198 -0.639] - [-1.145 1.198 0.963] - [ 0.232 0.066 -1.198] - [ 1.038 -1.198 -0.191] - [-0.913 0.008 -1.198] - [-0.556 1.198 0.689] - [-1.198 0.44 0.598] - [-1.198 0.515 -0.813] - [-0.365 -0.946 1.198] - [ 1.198 0.357 -0.116] - [ 0.93 0.481 1.198] - [-0.581 -0.058 1.198] - [-0.88 -1.198 -0.008] - [-1.198 0.34 0.141]] \ No newline at end of file +[[ 0. 0.334 0.035] + [-0.307 -0.232 0.266] + [ 0.025 0.315 -0.242] + [ 0.122 -0.49 -0.202] + [-0.402 -0.33 0.1 ] + [-0.295 -0.395 -0.237] + [-0.166 -0.312 -0.054] + [ 0.129 0.083 0.188] + [-0.002 0.661 0.032] + [-0.034 0.381 -0.247] + [ 0.149 0.646 0.106] + [-0.032 -0.257 0.193] + [-0.074 -0.34 0.017] + [-0.138 -0.504 -0.158] + [ 0.08 -0.319 -0.212] + [ 0.016 0.423 -0.166] + [-0.136 0.387 -0.08 ] + [ 0.196 0.349 0.229] + [ 0.039 -0.179 0.22 ] + [-0.1 0.25 -0.102] + [-0.089 0.247 -0.019] + [ 0.092 0.415 0.114] + [-0.228 -0.452 -0.095] + [-0.162 0.021 0.08 ] + [-0.006 0.113 0.02 ] + [-0.007 -0. -0.091] + [ 0.126 0.86 0.087] + [ 0.187 0.362 0.154] + [ 0.075 -0.332 -0.35 ] + [ 0.075 0.161 -0.108] + [ 0.03 0.209 -0.069] + [ 0.108 0.549 -0.05 ] + [-0.256 -0.564 -0.05 ] + [ 0.079 -0.312 0.088] + [-0.083 -0.21 0.224] + [-0.207 -0.467 0.098] + [-0.017 -0.281 -0.06 ] + [ 0.041 -0.176 -0.099] + [ 0.069 -0.277 -0.404] + [ 0.163 -0.183 -0.121] + [ 0.075 0.895 0.003] + [-0.249 -0.429 -0.111] + [ 0.311 0.279 -0.046] + [-0.129 0.304 -0.045] + [ 0.188 -0.128 -0.105] + [ 0.059 0.653 0.049] + [ 0.137 -0.27 -0.179] + [-0.232 -0.43 0.075] + [-0.362 -0.357 0.064] + [-0.01 0.768 -0.018] + [-0.079 -0.6 -0.328] + [ 0.083 0.066 0.066] + [-0.025 -0.343 0.291] + [ 0.025 0.37 -0.278] + [-0.187 0.021 0.261] + [ 0.166 0.307 -0.134] + [-0.017 0.347 -0. ] + [ 0.046 0.892 -0.029] + [ 0.105 0.81 -0.096] + [ 0.077 0.366 -0.225] + [-0.178 -0.385 -0.224] + [ 0.028 0.606 -0.002] + [ 0. -0.299 -0.082] + [ 0.058 -0.454 -0.254] + [ 0.008 0.101 -0.124] + [ 0.116 -0.199 -0.034] + [-0.116 -0.59 -0.056] + [-0.017 -0.356 0.091] + [-0.017 0.811 -0.011] + [-0.196 -0.163 0.103] + [-0.232 -0.564 0.033] + [ 0.087 0.245 -0.129] + [ 0.074 0.374 0.191] + [-0.118 -0.033 -0.024] + [-0.155 0.359 0.053] + [-0.227 -0.241 0.252] + [ 0.02 0.14 0.042] + [ 0.128 0.083 0.188] + [ 0.099 -0.338 -0.258] + [-0.118 -0.44 0.048] + [ 0.179 0.212 0.087] + [-0.143 0.242 -0.032] + [-0.062 -0.153 0.26 ] + [ 0.017 0.255 -0.132] + [-0.06 -0.515 -0.33 ] + [-0.142 -0.431 0.23 ] + [ 0.011 0.058 -0.081] + [-0.091 -0.418 -0.347] + [ 0.083 0.835 -0.011] + [-0.119 -0.079 0.159] + [-0.246 -0.284 -0.266] + [-0.14 -0.059 -0.058] + [-0.263 -0.018 -0.04 ] + [-0.147 -0.548 -0.282] + [ 0.136 -0.124 0.131] + [-0.097 -0.211 0.091] + [-0.05 0.057 -0.036] + [ 0.079 0.277 -0.047] + [ 0.029 0.352 0.103] + [ 0.041 0.378 -0.037]] \ No newline at end of file diff --git a/tests/snapshots/test_load/test_style_positions/8U8W-surface/position.txt b/tests/snapshots/test_load/test_style_positions/8U8W-surface/position.txt index 7b31248e..3ab5814a 100644 --- a/tests/snapshots/test_load/test_style_positions/8U8W-surface/position.txt +++ b/tests/snapshots/test_load/test_style_positions/8U8W-surface/position.txt @@ -82,7 +82,7 @@ [-0.24 0.049 0.373] [-0.427 -0.162 0.138] [-0.174 -0.2 0.225] - [-0.326 -0.151 0.367] + [-0.326 -0.152 0.367] [-0.474 -0.177 0.198] [-0.2 -0.148 -0.008] [-0.175 -0.161 0.081] diff --git a/tests/test_density.py b/tests/test_density.py index 18b5d04e..3bd888b4 100644 --- a/tests/test_density.py +++ b/tests/test_density.py @@ -44,13 +44,13 @@ def test_density_load(density_file): def test_density_centered(density_file): + # First load using standard parameters to test recreation of vdb + # o = mn.io.density.load(density_file).object + # # Then refresh the scene + # bpy.data.objects.remove(o, do_unlink=True) + bpy.ops.wm.read_homefile(app_template="") - # First load using standar parameters to test recreation of vdb - o = mn.io.density.load(density_file).object - # Then refresh the scene - bpy.data.objects.remove(o, do_unlink=True) - - obj = mn.io.density.load(density_file, center=True).object + obj = mn.io.density.load(density_file, center=True, overwrite=True).object evaluated = mn.blender.obj.evaluate_using_mesh(obj) pos = mn.blender.obj.get_attribute(evaluated, "position") @@ -126,10 +126,13 @@ def test_density_operator(snapshot, density_file, invert, node_setup, center): scene.MN_import_node_setup = node_setup scene.MN_import_density_center = center scene.MN_import_density_name = "" + bobs = [bob.name for bob in bpy.data.objects] bpy.ops.mn.import_density() - object = bpy.data.objects['emd_24805'] + for bob in bpy.data.objects: + if bob.name not in bobs: + new_bob = bob snapshot.assert_match( sample_attribute_to_string( - mn.blender.obj.evaluate_using_mesh(object), 'position'), + mn.blender.obj.evaluate_using_mesh(new_bob), 'position'), "invert_nodesetup_center_positions.txt" )