Instantly share code, notes, and snippets.

@rondreas
rondreas / countScriptCtx.py
Created Dec 7, 2018
Count the number of scriptCtx in scene, checking only default named ones.
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()):
@rondreas
rondreas / eSelection.py
Created Nov 20, 2018
snippet for blog post on toggleComponent
View eSelection.py
class eSelection(object):
""" Enum for selection convertion. """
object = 0
face = 1
edge = 2
vert = 3
@rondreas
rondreas / toggleComponents.py
Created Nov 19, 2018
Quick script to allow hotkeying a toggle for converting selection, to imitate the default command of CTRL + F9/F10/F11.
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):
@rondreas
rondreas / fixNormals.py
Last active Nov 19, 2018
hardsurface modelling script to set normals for all vertices on a face.
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
@rondreas
rondreas / VertexWind.shader
Created Oct 11, 2018
Vertex displacement shader to simulate wind.
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
@rondreas
rondreas / Replacer.cs
Created Oct 10, 2018
Unity Editor Tool to attempt replace selected GameObjects with any asset matching the name of selected.
View Replacer.cs
using UnityEngine;
using UnityEditor;
public class Replacer : EditorWindow
{
[MenuItem("Window/Replacer")]
public static void ShowWindow()
{
EditorWindow.GetWindow<Replacer>("Replace GameObject");
}