Skip to content

Commit

Permalink
Updated so we can see ovito-computed properties
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrunnels committed Nov 21, 2023
1 parent 7f77837 commit d7f3f9c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 35 deletions.
42 changes: 27 additions & 15 deletions bleMD/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 1 addition & 20 deletions bleMD/bleMDProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit d7f3f9c

Please sign in to comment.