From d7f3f9c6785638c0d5301724b3362923d836190f Mon Sep 17 00:00:00 2001 From: Brandon Runnels Date: Tue, 21 Nov 2023 07:28:53 -0700 Subject: [PATCH] Updated so we can see ovito-computed properties --- bleMD/__init__.py | 42 ++++++++++++++++++++++++++-------------- bleMD/bleMDProperties.py | 21 +------------------- 2 files changed, 28 insertions(+), 35 deletions(-) diff --git a/bleMD/__init__.py b/bleMD/__init__.py index 7828b2a..aa314a9 100644 --- a/bleMD/__init__.py +++ b/bleMD/__init__.py @@ -40,31 +40,43 @@ def startOvito(): filename = bpy.context.scene.bleMD_props.lammpsfile interp = bpy.context.scene.bleMD_props.lammps_frame_stride + scene = bpy.context.scene + mytool = scene.bleMD_props + # + # Load the file + # from ovito.io import import_file pipeline = import_file(filename, sort_particles=True) + # + # Execute User's Ovito Python script if applicable + # if "Ovito" in bpy.data.texts.keys(): exec(bpy.data.texts['Ovito'].as_string()) - #from ovito.modifiers import UnwrapTrajectoriesModifier - #from ovito.modifiers import WrapPeriodicImagesModifier - - # Load pipeline from ovito - - # Check if checkboxes are ticked in the panel - # If so, apply the appropriate modifier to the ovito - # pipeline - #if bpy.context.scene.bleMD_props.ovito_wrap_periodic_images: - # pipeline.modifiers.append(WrapPeriodicImagesModifier()) - #if bpy.context.scene.bleMD_props.ovito_unwrap_trajectories: - # pipeline.modifiers.append(UnwrapTrajectoriesModifier()) - - # Note the number of timestep dumps + # + # Adjust number of frames + # nframes = pipeline.source.num_frames - bpy.context.scene.bleMD_props.number_of_lammps_frames = nframes + mytool.number_of_lammps_frames = nframes + bpy.context.scene.frame_end = nframes * mytool.lammps_frame_stride + mytool.valid_lammps_file = True + + # + # Populate the properties list + # + data = pipeline.compute() + props = list(data.particles.keys()) + scene.datafieldlist.clear() + for prop in props: + item = scene.datafieldlist.add() + item.name = prop + if prop == "Position": + item.enable = True + item.editable = False return pipeline diff --git a/bleMD/bleMDProperties.py b/bleMD/bleMDProperties.py index 4b4a5c0..1723754 100644 --- a/bleMD/bleMDProperties.py +++ b/bleMD/bleMDProperties.py @@ -59,27 +59,8 @@ def updateFrameStride(self, context): ) def openLAMMPSFile(self, context): - scene = context.scene - mytool = scene.bleMD_props - - import ovito - from ovito.io import import_file - pipeline = import_file(mytool.lammpsfile, sort_particles=True) - nframes = pipeline.source.num_frames - mytool.number_of_lammps_frames = nframes - bpy.context.scene.frame_end = nframes * mytool.lammps_frame_stride - mytool.valid_lammps_file = True - - data = pipeline.compute() - props = list(data.particles.keys()) + startOvito() - scene.datafieldlist.clear() - for prop in props: - item = scene.datafieldlist.add() - item.name = prop - if prop == "Position": - item.enable = True - item.editable = False lammpsfile: StringProperty( name="LAMMPS Dump File",