Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Rånman rondreas

View GitHub Profile
@rondreas
rondreas / modo_monitor_example.py
Created Mar 2, 2021
Experimented with implementing a progress bar for longer tasks in Modo, didn't quite get it to work due to focus being stolen from rendering.
View modo_monitor_example.py
import lx
from time import sleep
SECONDS = 15
# Initialize the monitor object, ie progress bar.
monitor = lx.Monitor()
monitor.init(SECONDS)
# Mimic a long operation that users might want to stop.
View unreal_on_asset_import.py
import unreal
@unreal.uclass()
class OnAssetPostImportAction(unreal.EditorUtilityObject):
@unreal.ufunction(override=True)
def run(self):
""" Add a callable static function to be called whenever an asset is
imported.
@rondreas
rondreas / restore_defaults.py
Created Apr 15, 2020
Fire and forget script to parse and restore a kits default configuration.
View restore_defaults.py
# python
# -*- coding: utf-8 -*-
"""
Fire and forget script to parse and restore a kits default configuration.
>>> @restore_defaults.py myKit
"""
@rondreas
rondreas / ue_spawn_blutility.py
Created Mar 12, 2020
Open the Widget for a Blueprint Widget Utility
View ue_spawn_blutility.py
"""
Open the Widget for a Blueprint Widget Utility
"""
import unreal
def main():
@rondreas
rondreas / cube.py
Created Mar 3, 2020
Script to create a mesh cube using Modo TD SDK
View cube.py
# 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 Jan 17, 2020
Context manager for setting temporary pref.value(s) during a context.
View PreferenceValues.py
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 Dec 3, 2019
Example of a Form Command List with a Notifier and Command to call for the list to update.
View commands.py
"""
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 Dec 10, 2019
Advent of Code 2019, Day 3
View aoc_2019_03.rs
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 Dec 2, 2019
Advent of Code 2019, Day 02
View aoc_2019_02.rs
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 Dec 1, 2019
Advent of Code 2019, Day 1
View aoc_2019_01.rs
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(){