Skip to content

Instantly share code, notes, and snippets.

View rondreas's full-sized avatar

Andreas Rånman rondreas

View GitHub Profile
@rondreas
rondreas / unreal_menu.py
Created April 1, 2021 08:08
Example of extending a menu in Unreal using Python
"""
Example of extending a menu in Unreal using Python
"""
import unreal
def main():
//
// Advent of Code 2023 - Day 5: If You Give A Seed A Fertilizer
//
use std::ops::Range;
use std::cmp::min;
fn main() {
// replace CR LF with LF, to run nicely on windows also,
let input = include_str!("input.txt").replace("\r\n", "\n");
use std::collections::HashSet;
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
enum HandType {
HighCard,
OnePair,
TwoPair,
ThreeOfAKind,
FullHouse,
FourOfAKind,
@rondreas
rondreas / wait_for_it.rs
Created December 6, 2023 07:55
Advent of Code 2023 Day 6: Wait For It
fn main() {
// test input
let times = [7u64, 15u64, 30u64];
let distances = [9u64, 40u64, 200u64];
for time_held in 1..6 {
let time_left = 7 - time_held;
let distace_travelled = time_held * time_left;
if distace_travelled > 9 {
}
@rondreas
rondreas / delete_vmap.cfg
Created November 21, 2023 12:46
Modo is missing a mesh operator for deleting vertex maps, here it is as a Python plugin
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<atom type="CommandHelp">
<hash type="Item" key="py.delete.vmap@en_US">
<atom type="UserName">Delete Vertex Map</atom>
<hash type="Channel" key="name">
<atom type="UserName">Name</atom>
</hash>
<hash type="Channel" key="type">
<atom type="UserName">Type</atom>
@rondreas
rondreas / HelloWorld.cpp
Created April 17, 2023 13:56
Minimal example of what is required to make a console command
#include "HAL/IConsoleManager.h"
#if !UE_BUILD_SHIPPING
static FAutoConsoleCommand HelloWorld(
TEXT("hello.world"),
TEXT("Print Hello, World! to the console log"),
FConsoleCommandDelegate::CreateLambda([](){
GLog->Log(TEXT("Hello, World!"));
})
);
@rondreas
rondreas / ue_menu.py
Created February 27, 2023 08:45
Another unreal menu, extending the context menu for folders in the content browser
import unreal
@unreal.uclass()
class MyEntry(unreal.ToolMenuEntryScript):
@unreal.ufunction(override=True)
def execute(self, context):
print("Hello!")
@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 / get_ifc.py
Created September 22, 2022 08:57
Often you end up getting a lx.object.Unknown from Modo's API, this will test the object against all "interfaces" and return list of potentially supported types.
import lx
def get_ifc(obj):
""" From a given object in lx sdk, find supported interfaces"""
supported_interfaces = []
for name, ifc in lx.object.__dict__.items():
try:
if isinstance(ifc, type):
o = ifc(obj)
supported_interfaces.append(ifc)
@rondreas
rondreas / get_static_meshes.py
Created February 17, 2023 11:32
Testing new asset registry method for getting assets by class
import unreal
if __name__ == "__main__":
asset_registry = unreal.AssetRegistryHelpers.get_asset_registry()
static_class = unreal.StaticMesh.static_class()
package = static_class.get_package()
top_level_asset = unreal.TopLevelAssetPath(package.get_name(), static_class.get_name())
static_meshes = asset_registry.get_assets_by_class(top_level_asset)