This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy, os | |
| def importAll(strFolder): | |
| for strFile in os.listdir(strFolder): | |
| strPath = os.path.join(strFolder, strFile) | |
| if os.path.isdir(strPath): | |
| #recursive call to self to look in subdirectories | |
| importAll(strPath) | |
| elif strFile.lower().endswith('.glb') or strFile.lower().endswith('.gltf'): | |
| bpy.ops.import_scene.gltf(filepath=strPath, files=[{"name":strFile}], loglevel=50) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # limit, first value is current position | |
| -17 if -7 + (frame * 1.0) <= -17 else 2 if -7 + (frame * 1) >= 2 else -7 + (frame * 1) | |
| # frame range, first value is current position | |
| 20.0 + (smoothstep(3,250,frame) * 247 * 1.0) | |
| # wrapping the value in , first value is current position | |
| sin(178 + (smoothstep(3,250,frame) * 247 * 1.0)) | |
| #reference another objects properties, where 0=x in the axis number (x,y,z) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getGeometryNodeParam(obj,strModiferName, arrFind): | |
| # find the input ID for a given set of strings to match | |
| # inputID = getGeometryNodeParam(obj, "modifierName",['findme ','andme']) | |
| # to set a input param = obj.modifiers['modifierName'][inputID] = objCollection | |
| if strModiferName in obj.modifiers.keys(): | |
| for input in obj.modifiers[strModiferName].node_group.inputs: | |
| for strFind in arrFind: | |
| if input.name.lower().find(strFind) == -1: | |
| break | |
| return input.identifier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def appendNew(strPath, strLibrary, arrExclude = []): | |
| # append objects from a Library in a file ONLY if they are new | |
| # appendNew(relativePath.blend,'collections') | |
| # you still need to LINK the objects to things after this | |
| with bpy.data.libraries.load(os.path.join(getLocation(), strPath)) as (data_from, data_to): | |
| arrNew = [] | |
| for strName in getattr(data_from, strLibrary): | |
| isNew = True | |
| for strExclude in arrExclude: | |
| if strExclude == strName: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getAverageNormal(arrVerts): | |
| return sum([v.normal for v in arrVerts], mathutils.Vector()) / len(arrVerts) | |
| def fnTranslateVectors(arrVerts): | |
| # Translate the vector into a flattened 2d coordinate | |
| avg_normal = getAverageNormal(arrVerts) | |
| rot_quat = avg_normal.rotation_difference((0, 0, 1)) | |
| return rot_quat, [(rot_quat @ v.co).to_2d() for v in arrVerts] | |
| def alignObjectToVerts(obj, arrVerts): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def origin_to(ob, o, matrix=Matrix()): | |
| # object, xyz location | |
| me = ob.data | |
| mw = ob.matrix_world | |
| o = matrix.inverted() @ o | |
| me.transform(Matrix.Translation(-o)) | |
| mw.translation = mw @ o |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy, bmesh, mathutils | |
| # Blender script to get selected faces and create a new flat plan from the shapoe | |
| def createDelaunay(points): | |
| vs = [mathutils.Vector(co[:2]) for co in points] | |
| # mathutils.geometry.delaunay_2d_cdt(vert_coords, edges, faces, output_type, epsilon, need_ids=True) | |
| result = mathutils.geometry.delaunay_2d_cdt(vs, [], [], 0, 0.001) | |
| vertices, edges, faces = result[:3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bl_info = { | |
| "name": "Crayon", | |
| "author": "Anthony Aragues", | |
| "version": (0, 9), | |
| "blender": (3,0,0), | |
| "location": "n > Crayon", | |
| "description": "vertex paint your objects by chosen colors quickly", | |
| "warning": "", | |
| "doc_url": "http://3dialogue.com/addons/crayon", | |
| "category": "Import-Export", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # move origin for all selected objects to edges of axis example usage, where xyz=012 | |
| # left = origin_to(obj,0,"-"), right = origin_to(obj,0,"+") | |
| def origin_to(ob, axis="z", dir="-", matrix=Matrix()): | |
| me = ob.data | |
| mw = ob.matrix_world | |
| local_verts = [matrix @ Vector(v[:]) for v in ob.bound_box] | |
| o = sum(local_verts, Vector()) / 8 | |
| if dir == "-": | |
| o[axis] = min(v[axis] for v in local_verts) | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy | |
| #define what the property in the colection will look like | |
| class color_map(bpy.types.PropertyGroup): | |
| color: bpy.props.FloatVectorProperty( | |
| name = "Color Picker", | |
| subtype = "COLOR", | |
| default = (1.0,1.0,1.0,1.0), | |
| size = 4 | |
| ) |