Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Rånman rondreas

View GitHub Profile
@rondreas
rondreas / build.bat
Created Dec 14, 2021
Thank you handmade hero for making it easier to compile stuff
View build.bat
@echo off
REM adds cl.exe to path
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64
REM Set current dir to folder of this script
pushd %~dp0
REM Then create and cd into build folder
mkdir build
View modo_perforce_progress.py
# python
import lx
from P4 import P4
from P4 import Progress
from P4 import P4Exception
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 / check_ubx.py
Created Jun 17, 2021
Check if mesh is a cube that would be accepted as a unreal collision volume
View check_ubx.py
import lx
import lxu
import modo
from math import isclose
mesh, = modo.Scene().selectedByType('mesh')
result = set()
with mesh.geometry as geo:
normals = set()
@rondreas
rondreas / xformMirror.py
Last active Jun 8, 2021
Script to mirror transform similar to Maya's Joint Mirror Tool.
View xformMirror.py
import pymel.core as pm
def xformMirror(transforms=[], across='YZ', behaviour=True):
""" Mirrors transform across hyperplane.
transforms -- list of Transform or string.
across -- plane which to mirror across.
behaviour -- bool
"""
@rondreas
rondreas / sheet_conflict.py
Created May 24, 2021
Had issue where some artists had copied configs from another machine and ui elements would just be gone or they'd suffer constant crashes. Figured it could be conflicts in their configs so threw this one together and seems to have solved our issues.
View sheet_conflict.py
import xml.etree.ElementTree as ET
import os
platform = lx.service.Platform()
configs = set() # all unique paths to config files
for i in range(platform.ImportPathCount()):
directory = platform.ImportPathByIndex(i)
for filename in os.listdir(directory):
@rondreas
rondreas / Hello.cpp
Created May 4, 2021
Hello world for Modo
View Hello.cpp
#include <lx_log.hpp>
#include <lxu_log.hpp>
#include <lxu_command.hpp>
#define SRVNAME_COMMAND "hello.world"
class CHelloCommand : public CLxCommand
{
public:
CLxUser_LogService log_service;
@rondreas
rondreas / unreal_menu.py
Created Apr 1, 2021
Example of extending a menu in Unreal using Python
View unreal_menu.py
"""
Example of extending a menu in Unreal using Python
"""
import unreal
def main():
@rondreas
rondreas / pix_rt_dump.py
Created Apr 1, 2021
read a file with render thread data as csv from pix and print out function names and times function was called.
View pix_rt_dump.py
"""
Given a flat list copy pasted as csv from PIX Timing capture, list unique names
"""
def main():
names = list()
with open("renderthread_dump.csv", 'r') as f:
@rondreas
rondreas / line_count.py
Created Apr 1, 2021
Tool to get a quick overview of number of files and lines of text
View line_count.py
import os
import sys
import re
import argparse
def main():
parser = argparse.ArgumentParser(
description="Tool to get a quick overview of number of files and lines of text"
)