def execute(self, context): dm = {} dm['mcell'] = examples.variable_rate_constant.variable_rate_constant_dm cellblender.replace_data_model(dm, geometry=True) view_all() return {'FINISHED'}
def execute(self, context): dm = {} dm['mcell'] = examples.dynamic_geometry.dynamic_geometry_dm cellblender.replace_data_model(dm, geometry=True, scripts=True) # load object with shape keys from blend file blendfile = os.path.join(os.path.dirname(__file__), "./examples/dynamic_geometry.blend") section = "/Object/" obj = "Cube" filepath = blendfile + section + obj directory = blendfile + section filename = obj bpy.ops.wm.append(filepath=filepath, filename=filename, directory=directory) # set it to be dynamic and make transparent bpy.context.scene.mcell.model_objects.object_list[0].dynamic = True bpy.data.objects["Cube"].show_transparent = True bpy.data.materials["Cube_mat"].use_transparency = True bpy.data.materials["Cube_mat"].alpha = 0.2 view_all() return {'FINISHED'}
def execute(self, context): dm = {} dm['mcell'] = examples.direct_transport_BNGL.direct_transport_bngl_dm cellblender.replace_data_model(dm, geometry=True) view_all() return {'FINISHED'}
def execute(self, context): dm = {} dm['mcell'] = examples.lipid_raft.lipid_raft_dm cellblender.replace_data_model(dm, geometry=True) view_all() return {'FINISHED'}
def execute(self, context): dm = {} dm['mcell'] = examples.mind_mine_system.mind_mine_dm cellblender.replace_data_model(dm, geometry=True) view_all() return {'FINISHED'}
def execute(self, context): dm = {} dm['mcell'] = examples.ficks_laws.ficks_law_3D_dm cellblender.replace_data_model(dm, geometry=True, scripts=True) view_all() return {'FINISHED'}
def execute(self, context): dm = {} dm['mcell'] = examples.tlbr_mcell3r.tlbr_mcell3r_dm cellblender.replace_data_model(dm, geometry=True, scripts=False) view_all() return {'FINISHED'}
def execute(self, context): dm = {} dm['mcell'] = examples.simple_coil_mcell3r.simple_coil_mcell3r_dm cellblender.replace_data_model(dm, geometry=True) view_all() bpy.ops.view3d.viewnumpad(type='TOP') hide_manipulator(hide=True) return {'FINISHED'}
def execute(self, context): dm = {} dm['mcell'] = examples.pbc.pbc_dm clear_texts() mdl_name = 'pbc.mdl' pbc_txt = bpy.data.texts.new(mdl_name) pbc_txt.write(dm['mcell']['scripting']['script_texts'][mdl_name]) cellblender.replace_data_model(dm, geometry=True) bpy.ops.view3d.snap_cursor_to_center() bpy.ops.mesh.primitive_cube_add() bpy.context.scene.objects.active.scale = (0.5, 0.1, 0.1) bpy.context.object.draw_type = 'WIRE' view_all() return {'FINISHED'}
def execute(self, context): dm = {} dm['mcell'] = examples.rat_nmj.rat_nmj_dm clear_texts() param_mdl_name = 'rat_nmj.parameters.mdl' parameters_txt = bpy.data.texts.new(param_mdl_name) parameters_txt.write( dm['mcell']['scripting']['script_texts'][param_mdl_name]) release_mdl_name = 'rat_nmj.release_sites.mdl' release_sites_txt = bpy.data.texts.new(release_mdl_name) release_sites_txt.write( dm['mcell']['scripting']['script_texts'][release_mdl_name]) cellblender.replace_data_model(dm, geometry=True) view_all() return {'FINISHED'}
def execute(self, context): dm = {} dm['mcell'] = examples.dyn_geo_conc_clamp.dyn_geo_cc_dm cellblender.replace_data_model(dm, geometry=True, scripts=True) # Default frame_start is 1, set to 0 to match model context.scene.frame_start = 0 context.scene.update() # Set the frame to 50 (large cube) so the view all operator will fit at max size (not really needed for scripting) context.scene.frame_current = 50 # Set the view to show the selected object context.scene.update() # Add a cube tepmorarily to use for centering the view bpy.ops.mesh.primitive_cube_add() bpy.context.scene.objects.active.location.z = 3 view_all() # This zooming seems to have no effect # zoom_view(-500) # Remove the temporary cube that was used for centering the view bpy.ops.object.delete(use_global=False) # Re-select the original cube bpy.data.objects[ 'Cube'].select = True # This selects it (enables manipulator on the object) context.scene.objects.active = bpy.data.objects[ 'Cube'] # This makes it active for material display etc # Return the current frame to 0 (small cube) after viewing large cube (not really needed for scripting) context.scene.frame_current = 0 return {'FINISHED'}
def execute(self, context): # Start by loading the data model and placing into CellBlender properties dm = {} dm['mcell'] = examples.shape_key_dyn_geo.shape_key_dyn_geo_dm cellblender.replace_data_model(dm, geometry=True, scripts=False) # Select the Cube object (created by the data model) obj = bpy.data.objects['Cube'] obj.select = True context.scene.objects.active = obj # Remove all previous shape keys (otherwise this can't be run twice!!) # Suggestion from cmomoney: # https://blenderartists.org/forum/showthread.php?243733-Shape-Key-Removal&p=3177866&viewfull=1#post3177866 #if obj.data.shape_keys: # This is never executed because obj.data.shape_keys is None # The problem isn't how to delete from the object, but how to delete from bpy.data.shape_keys # for k in obj.data.shape_keys.key_blocks: # obj.shape_key_remove(k) # https://blender.stackexchange.com/questions/27193/how-do-i-delete-one-single-shape-key # Shape keys can be added and deleted through the Properties editor (the on the right ) under the Data tab in Shape keys. # Note that you have to be in Object Mode for this to work... otherwise the minus sign will be greyed out! # https://blenderartists.org/forum/showthread.php?283867-Delete-All-Shape-Keys # Try this in the python console: # [bpy.ops.object.shape_key_remove() for x in range(50)] # It's a hack, but it should work! # https://blenderartists.org/forum/showthread.php?233730-delete-shape-key-by-name-via-python # delete shape key by name via python # Q. how to delete shapekey by name from python... # foreach_get_howto.jpgforeach_get_howto.jpg # i can get shapekey names via # #### iterate over existing shapekeys # obj = bpy.context.object # sk = obj.data.shape_keys # skNamesArr = sk.key_blocks # for each in skNamesArr: # print each # ########################## # #### adding shape keys # obj.shape_key_add("nameStr") # ########################## # #### removing by name seems hard... # bpy.ops.object.shape_key_remove() # this will remove selected shape key. # # how to give it parameter/ datapath from above lines(where i m iterating over sk) # or how to select a shapekey from list by name, ?? # another question(thanks in advance for taking time n helping me out) # Q. how to use function "foreach_get" or "foreach_set" in most of blender returned data objects.?? #you could wrap it like this: #Code: #import bpy #def deleteShapekeyByName(oObject, sShapekeyName): # # # setting the active shapekey # iIndex = oObject.data.shape_keys.key_blocks.keys().index(sShapekeyName) # oObject.active_shape_key_index = iIndex # # # delete it # bpy.ops.object.shape_key_remove() # #oActiveObject = bpy.context.active_object #deleteShapekeyByName(oActiveObject, "MyShapeKey") try: # This currently fails with: # RuntimeError: Operator bpy.ops.object.shape_key_remove.poll() failed, context is incorrect # Keep it here until we figure out how to make it work!! bpy.ops.object.shape_key_remove(all=True) except: pass # Add two shape keys bpy.ops.object.shape_key_add(from_mix=False) # Adds "Basis" Shape Key bpy.ops.object.shape_key_add(from_mix=False) # Adds "Key 1" Shape Key # Temp fix - this works, # but additional shape keys are added to: # bpy.data.shape_keys.keys # every time the example is loaded. # key_to_modify = bpy.data.shape_keys['Key'] key_to_modify = bpy.data.shape_keys[-1] print("Current bpy.data.shape_keys.keys() = " + str(bpy.data.shape_keys.keys())) # Enter Edit Mode and deselect all bpy.ops.object.mode_set(mode="EDIT") bpy.ops.mesh.select_all(action='DESELECT') # Move the top 4 points when on "Key 1" (the default key after the previous adds) obj = context.object mesh = obj.data bm = bmesh.from_edit_mesh(mesh) bm.verts.ensure_lookup_table() verts = bm.verts for v in verts: if v.co[2] > 0: # This is a positive (top) vertex so stretch it v.co[0] = v.co[0] * 0.25 v.co[1] = v.co[1] * 0.25 v.co[2] = 3.0 bmesh.update_edit_mesh(mesh) # Return to Object Mode bpy.ops.object.mode_set(mode="OBJECT") # Default frame_start is 1, set to 0 to match shape key assignments context.scene.frame_start = 0 # Assign the shape keys to complete one cycle every 100 frames context.scene.frame_current = 0 key_to_modify.key_blocks["Key 1"].value = 0.0 mesh.shape_keys.key_blocks['Key 1'].keyframe_insert(data_path='value') context.scene.frame_current = 100 key_to_modify.key_blocks["Key 1"].value = 1.0 mesh.shape_keys.key_blocks['Key 1'].keyframe_insert(data_path='value') context.scene.frame_current = 200 key_to_modify.key_blocks["Key 1"].value = 0.0 mesh.shape_keys.key_blocks['Key 1'].keyframe_insert(data_path='value') # Set the frame to 50 (large cube) so the view all operator will fit at max size context.scene.frame_current = 100 # Switch area type to set the F-Curve modifier to "CYCLES" area = bpy.context.area old_type = area.type area.type = 'GRAPH_EDITOR' bpy.ops.graph.fmodifier_add(type='CYCLES') area.type = old_type # Set the view to show the selected object context.scene.update() view_all() # Return the current frame to 0 (small cube) after viewing large cube context.scene.frame_current = 0 return {'FINISHED'}
'data_model_version' : "DM_2014_10_24_1638", 'fwd_rate' : "fr", 'name' : "r_%d -> NULL" % (i+1), 'products' : "NULL", 'reactants' : "m_%d" % ((i%nmols)+1), 'rxn_name' : "", 'rxn_type' : "irreversible", 'variable_rate' : "", 'variable_rate_switch' : False, 'variable_rate_text' : "", 'variable_rate_valid' : False } rlist.append ( r ) i += 1 path += delta mcell['initialization']['iterations'] = str(i) patterns['release_pattern_list'] = plist mcell['define_release_patterns'] = patterns sites['release_site_list'] = slist mcell['release_sites'] = sites reactions['reaction_list'] = rlist mcell['define_reactions'] = reactions mcell['geometrical_objects'] = { 'object_list' : [] } mcell['model_objects'] = { 'data_model_version' : "DM_2014_10_24_1638", 'model_object_list' : [] } cb.replace_data_model ( dm, geometry=True )