xdatbus.utils_bpy ================= .. py:module:: xdatbus.utils_bpy Attributes ---------- .. autoapisummary:: xdatbus.utils_bpy.BPY_AVAILABLE xdatbus.utils_bpy.PDB_AVAILABLE xdatbus.utils_bpy.MN_AVAILABLE xdatbus.utils_bpy.YAML_AVAILABLE Functions --------- .. autoapisummary:: xdatbus.utils_bpy.realize_instances xdatbus.utils_bpy.remove_nodes xdatbus.utils_bpy.get_template_node xdatbus.utils_bpy.set_color4element xdatbus.utils_bpy.apply_yaml xdatbus.utils_bpy.clear_scene xdatbus.utils_bpy.render_image xdatbus.utils_bpy.apply_modifiers_to_mesh xdatbus.utils_bpy.yaml_gen xdatbus.utils_bpy.yaml_loader Module Contents --------------- .. py:data:: BPY_AVAILABLE :value: True .. py:data:: PDB_AVAILABLE :value: True .. py:data:: MN_AVAILABLE :value: True .. py:data:: YAML_AVAILABLE :value: True .. py:function:: realize_instances(obj, bond_radius) Realize instances of the given object. This function requires bpy. Parameters ---------- obj : bpy.types.Object The object to realize instances of bond_radius : float The radius of the bonds .. py:function:: remove_nodes(obj, node_names) Remove nodes with given names from the object's node tree. Parameters ---------- obj : bpy.types.Object The object from which to remove nodes. node_names : list of str The names of the nodes to remove. .. py:function:: get_template_node(node_name, nodes) Get a node from a template blend file. Parameters ---------- node_name : str The name of the node to get. nodes : bpy.types.NodeTree.nodes The nodes from the node tree to add the node to. Returns ------- node : bpy.types.Node The node from the template blend file. .. py:function:: set_color4element(obj, atomic_number, color, atomic_scale, bonded, bonded_count=0) Add a custom node and connect it to the specified input of the target node. Parameters ---------- obj : bpy.types.Object The object with the Geometry Nodes modifier whose node tree we're editing. atomic_number : int The atomic number of the element to set the color of. color : tuple The color to set the node to. atomic_scale : float The size of the atoms. bonded : bool Whether the atoms are bonded. bonded_count : int The number of elements forming a bond. .. py:function:: apply_yaml(obj, yaml_path) Set the color of the given object. This function requires bpy and molecularnodes. Parameters ---------- obj : bpy.types.Object The object to set the color of yaml_path : str The path to the YAML file to use .. py:function:: clear_scene(mesh=True, lights=True, geometry_nodes=True) Clear the scene of all objects. This function requires bpy. Parameters ---------- mesh : bool Clear mesh objects lights : bool Clear light objects geometry_nodes : bool Clear geometry node groups .. py:function:: render_image(engine='eevee', x=1000, y=500, output_path='render.png') Render an image. This function requires bpy. Parameters ---------- engine : str The render engine to use. Either 'eevee' or 'cycles' x : int The x resolution of the image y : int The y resolution of the image output_path : str The path to save the image to .. py:function:: apply_modifiers_to_mesh(obj) Apply modifiers to the given object. This function requires bpy. Parameters ---------- obj : bpy.types.Object The object to apply modifiers to .. py:function:: yaml_gen(pdb_file_path) This function generates a YAML file for the elements in the PDB file, with a common bond_radius. Parameters ---------- pdb_file_path : str Input path of the PDB file .. py:function:: yaml_loader(yaml_path) This function loads a YAML file and returns element data and bond radius. Parameters ---------- yaml_path : str Input path of the YAML file Returns ------- tuple A tuple containing a dictionary of elements with their properties and the common bond radius.