Skip to content

Instantly share code, notes, and snippets.

View rondreas's full-sized avatar

Andreas Rånman rondreas

View GitHub Profile
@rondreas
rondreas / cube.py
Created March 3, 2020 13:30
Script to create a mesh cube using Modo TD SDK
# python
# -*- coding: utf-8 -*-
import modo
def create():
""" Modo TD SDK example of creating a cube item,
Not recommended but one can run this as a fire-and-forget like..
@rondreas
rondreas / PreferenceValues.py
Created January 17, 2020 09:59
Context manager for setting temporary pref.value(s) during a context.
import lx
class PreferenceValue(object):
""" Context manager for setting temporary pref.value(s) during a context.
:param preferences: preferences to use for the context.
:type preferences: dict
Example::
@rondreas
rondreas / commands.py
Created December 3, 2019 10:01
Example of a Form Command List with a Notifier and Command to call for the list to update.
"""
Example of how to dynamically change a Form List Command.
We will implement a button that emits a notifier, which our form list
command will listen for when notified, it will refresh.
"""
import random
@rondreas
rondreas / aoc_2019_03.rs
Last active December 10, 2019 22:58
Advent of Code 2019, Day 3
use std::env;
use std::fs;
use std::ops;
use std::collections::HashSet;
use std::collections::HashMap;
#[derive(Clone, Copy, Hash, Eq, PartialEq, Debug)]
struct Point(i32, i32);
impl Point {
@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]);
@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 / 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 / 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 / texel_density.py
Last active February 22, 2023 06:54
Functions for getting and setting texel density in Maya
"""
Functions for editing the texel density
https://80.lv/articles/textel-density-tutorial/
"""
import math
import maya.cmds as mc
@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