Instantly share code, notes, and snippets.

View countScriptCtx.py
"""
Count the number of scriptCtx in scene, checking only default named ones.
"""
import pymel.core as pm
def countScriptCtx():
count = 0
mel_command = 'scriptCtx -ex "scriptCtx{}"'
View vertToObject.py
# Replace selection with transform, for all selected vertices.
pm.select( [shape.getTransform() for shape in pm.ls(pm.polyListComponentConversion( fromVertex = True ))], replace = True )
View getActive.py
def getActive():
""" Check current selection to find if we're currently only selecting a specific component. """
if all(isinstance(x, pm.MeshFace) for x in pm.selected()):
return eSelection.face
if all(isinstance(x, pm.MeshEdge) for x in pm.selected()):
return eSelection.edge
if all(isinstance(x, pm.MeshVertex) for x in pm.selected()):
View eSelection.py
class eSelection(object):
""" Enum for selection convertion. """
object = 0
face = 1
edge = 2
vert = 3
View toggleComponents.py
"""
Quick script to allow hotkeying a toggle for converting selection, to imitate the default
command of CTRL + F9/F10/F11.
"""
import pymel.core as pm
class eSelection(object):
View fixNormals.py
import pymel.core as pm
def faceNormal():
""" """
# Store old selection,
selection = pm.selected()
# Convert selection to faces,
pm.mel.ConvertSelectionToFaces()
View makelinks.py
View DrawSimple.shader
// Implementation of effect described at: https://willweissman.wordpress.com/tutorials/shaders/unity-shaderlab-object-outlines/
Shader "Custom/DrawSimple" {
SubShader{
ZWrite Off
ZTest Always
Lighting Off
Pass {
CGPROGRAM
#pragma vertex VShader
View VertexWind.shader
Shader "Custom/VertexWind" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness("Smoothness", Range(0,1)) = 0.5
_Metallic("Metallic", Range(0,1)) = 0.0
_Normal("Normal Map", 2D) = "bump" {}
_CutOff("Alpha Cutoff", Range(0, 1)) = 0.5
View Replacer.cs
using UnityEngine;
using UnityEditor;
public class Replacer : EditorWindow
{
[MenuItem("Window/Replacer")]
public static void ShowWindow()
{
EditorWindow.GetWindow<Replacer>("Replace GameObject");
}