Skip to content

Instantly share code, notes, and snippets.

@aobond2
aobond2 / RigExport.py
Last active May 9, 2024 10:16
Validate and export rig
"""
Maya/QT UI template
Maya 2023
"""
import maya.cmds as cmds
import maya.mel as mel
from maya import OpenMayaUI as omui
from shiboken2 import wrapInstance
from PySide2 import QtUiTools, QtCore, QtGui, QtWidgets
@aobond2
aobond2 / VertexColorToMaterial.py
Created July 31, 2023 14:46
Vertex color to material blender
import bpy
def create_material(color_name, color):
# Create a new material with the given color
mat = bpy.data.materials.new(name=color_name)
mat.use_nodes = True
nodes = mat.node_tree.nodes
principled_bsdf = nodes.get("Principled BSDF")
if principled_bsdf is not None:
Shader "UI/Procedural UI Image 2"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_Fade ("Fade", Float) = 1
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
def matchPlaceholderName():
# Function to rename placeholder to match the category name
# Select props collection
placeholderString = "Placeholder"
propsColl = bpy.context.collection
categoryArray = []
placeholderArray = []
placeholderCollection = bpy.data.collections[placeholderString]
if (propsColl.name == "Props"):
# Fill both array
def renameCollection_2():
categoryColl = bpy.context.collection
categoryName = categoryColl.name
pivotObject = None
shadowCatcherObject = None
prefix = "Prefix_"
if (checkCollectionNaming(categoryColl.name) == True):
# Set naming for collection
for childColl in categoryColl.children:
objectName = None
def repositionChildrenToPivot():
coll = bpy.context.collection
# Iterate on all object, separate into list of objects, pivot, shadow catcher
objectList = []
pivot = None
shadowCatcher = None
for c in coll.all_objects:
if ("Pivot" in c.name):
pivot = c
continue
@aobond2
aobond2 / change.py
Created November 17, 2022 11:05
Blender material change test
import bpy
def replace_material(obj, obj_data, mat_src, mat_dst):
"""
replace a material in blender.
"""
print("ob is", obj)
for i in range(len(obj_data.materials)):
# test if the old material is in the slot and replace it
try (closeRolloutFloater MainFloater) catch()
rollout LODCheck "LOD Checker"
(
spinner lodNumberSpinner "Max LOD number" type:#integer range:[0,5,3] align:#left
spinner reductionSpinner "Reduction percentage" type:#integer range:[0,100,50] align:#left
global nodeArray = #()
global reductionPercentage = 50
global maxLOD = 3
label menuLabel "Select an object/layer from layer explorer" align:#left
from math import pi
from random import random
import bpy
def delete_object(name):
if name in bpy.data.objects:
obj = bpy.data.objects[name]
obj.select_set(True)
bpy.ops.object.delete(use_global=False)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class GIDisabler : EditorWindow
{