Skip to content

Commit

Permalink
Some basic updates and edits, but no major fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrunnels committed Dec 6, 2023
1 parent ed84faa commit 9f2cbcc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
17 changes: 10 additions & 7 deletions bleMD/bleMDNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
def create_geonodes():
obj = bpy.data.objects["MD_Object"]

geo_nodes = obj.modifiers.get("build_geonode")
if geo_nodes:
return
#geo_nodes = obj.modifiers.get("build_geonode")
#if geo_nodes:
# return

geo_nodes = obj.modifiers.new("build_geonode", "NODES")

Expand All @@ -16,8 +16,8 @@ def create_geonodes():
def create_group(name="geonode_object"):
group = bpy.data.node_groups.get(name)
# check if a group already exists
if group:
return
#if group:
# return

group = bpy.data.node_groups.new(name, 'GeometryNodeTree')
#group.inputs.new('NodeSocketGeometry', "Geometry")
Expand Down Expand Up @@ -48,8 +48,8 @@ def create_group(name="geonode_object"):

def create_material():
mat = bpy.data.materials.get("my_mat")
if mat:
return
#if mat:
# return

mat = bpy.data.materials.new("my_mat")
obj = bpy.data.objects["MD_Object"]
Expand Down Expand Up @@ -99,6 +99,9 @@ def updateDefaultShader():


def defaultSettings():
if not bpy.context.scene.bleMD_props.override_defaults:
return

for scene in bpy.data.scenes:
scene.render.engine = 'CYCLES'

Expand Down
4 changes: 0 additions & 4 deletions bleMD/bleMDProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
from . bleMDUtils import *


def startOvito(hardrefresh=False):
print("Bob Lablaugh")


# ------------------------------------------------------------------------
# Scene Properties
# ------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions bleMD/bleMDUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ def loadUpdatedData(pipeline):
# Set up the object or grab the existing object
# TODO: how do we handle multiple objects?
if not "MD_Object" in bpy.data.objects.keys():
print("Creating new MD object")
# Object does not yet exist: create it
me = bpy.data.meshes.new("MD_Mesh")
ob = bpy.data.objects.new("MD_Object", me)
ob.show_name = True
bpy.context.collection.objects.link(ob)
else:
# Object exists: use it
print("Using existing")
ob = bpy.data.objects['MD_Object']
me = ob.data

Expand Down Expand Up @@ -131,6 +133,7 @@ def loadUpdatedData(pipeline):
#c_csym = [(1-fac)*x_lo + fac*x_hi for x_lo,x_hi in zip(data_lo.particles['c_csym'], data_hi.particles['c_csym'])]

if not len(me.vertices):
print("No vertices in mesh, creating new ones. Need {} vertices".format(len(coords)))
# Do this if the object has not been created yet
# This line actually creates all the points
me.from_pydata(coords, [], [])
Expand All @@ -141,6 +144,7 @@ def loadUpdatedData(pipeline):
attr = me.attributes.new(prop.name, 'FLOAT', 'POINT')
attr.data.foreach_set("value", attrs[prop.name])
else:
print("Updating existing vertex properties")
# We do this if we are just updating the positions and properties,
# not creating

Expand Down
6 changes: 6 additions & 0 deletions scripts/reinstall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import bpy
bpy.ops.preferences.addon_disable(module='bleMD')
bpy.ops.preferences.addon_remove(module='bleMD')
bpy.ops.preferences.addon_install(filepath="./bleMD.zip",overwrite=True)
bpy.ops.preferences.addon_enable(module='bleMD')
print("---successful completion---")

0 comments on commit 9f2cbcc

Please sign in to comment.