Skip to content

Instantly share code, notes, and snippets.

View rondreas's full-sized avatar

Andreas Rånman rondreas

View GitHub Profile
@rondreas
rondreas / countScriptCtx.py
Created December 7, 2018 11:55
Count the number of scriptCtx in scene, checking only default named ones.
"""
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{}"'
@rondreas
rondreas / PurgeTags.py
Created June 10, 2019 14:04
Purge tags for selected items
#python
"""
Remove all tags for selected items.
In Modo run:
> @PurgeTags.py
"""
@rondreas
rondreas / checksum.py
Last active September 24, 2019 15:45
#!/usr/bin/python3
import hashlib, sys
"""
Command line tool to get checksums in python.
Supply filepath for file to process, and which hash
method to use.
"""
@rondreas
rondreas / p4_multithreadded.py
Created October 17, 2019 08:49
Test to see that that official p4 api can be executed multithreadded
"""
Test to see that the official p4 api can be executed multithreadded
"""
# Get time so we can cause a delay, and uniform to set it to a random float,
from time import sleep
from random import uniform
@rondreas
rondreas / get_visible_meshes.py
Created October 28, 2019 12:36
Modo function for getting all visible meshes in current scene
import modo
# Anonymous function to wrap the lx query
is_visible = lambda item: bool(lx.eval('layer.setVisibility {} ?'.format(item.id)))
def get_visible_meshes():
meshes = modo.Scene().items(itype='mesh') # Get all mesh items in scene
return [mesh for mesh in meshes if is_visible(mesh)]
@rondreas
rondreas / list_kit_scripts.py
Last active November 6, 2019 14:08
Modo script to print all fire and forget scripts for the given kit to log.
# python
"""
Modo script to print all fire and forget scripts for the given kit to log.
Example::
@list_kit_scripts.py my_kit
@rondreas
rondreas / example_qworker.py
Last active November 18, 2019 15:54
Small QWorker example
"""
Small example for running a QWorker that sets a list
on completion.
"""
import time
import random
import sys
@rondreas
rondreas / hud_uv_coverage.py
Created November 29, 2019 15:43
Heads up display showing percentage of the UV area that current selected meshes/faces covers.
"""
Custom Heads up display, displaying the area current selection covers in UV space.
found this `gist <https://gist.github.com/SEVEZ/d86bf0a4a497794a94df8f125846ca4f>`_ from SEVEZ really useful.
"""
__author__ = "Andreas Ranman"
import maya.cmds as cmds
@rondreas
rondreas / aoc_2019_01.rs
Created December 1, 2019 10:34
Advent of Code 2019, Day 1
use std::env; // Get the standard library module for the process environment, so we can access arguments passed etc...
use std::fs; // Module for filesystem, so rust is aware of file objects
// The equation specified in the description for getting the fuel required to lift a given mass
fn required_fuel(mass: i32) -> i32 {
return mass / 3 - 2;
}
fn main(){
@rondreas
rondreas / aoc_2019_02.rs
Last active December 2, 2019 22:55
Advent of Code 2019, Day 02
use std::env;
use std::fs;
fn run(mut program: Vec<i32>) -> i32 {
for i in (0..program.len()).step_by(4) {
let operation = program[i]; // Operation to use, add/mult/break
let a = program[i+1] as usize;// Index to get first value from
let b = program[i+2] as usize;// Second value
let r = program[i+3] as usize;// Index to store result in
// println!("{} {} {} {}", program[i], program[i+1], program[i+2], program[i+3]);