Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Rånman rondreas

View GitHub Profile
View workplane_xfrm_inv.py
import lx
import lxu
# get the current active scene and a channel read object,
scene = lx.object.Scene(lxu.select.SceneSelection().current())
channel_read = lx.object.ChannelRead(scene.Channels(None, 0))
# using the channel read get the workplane position and rotation
workplane_position = scene.WorkPlanePosition(channel_read)
workplane_rotation = scene.WorkPlaneRotation(channel_read)
@rondreas
rondreas / list_notifiers.py
Created Feb 2, 2022
Iterate over all notifiers and get their arguments
View list_notifiers.py
import lx
notify_system = lx.service.NotifySys()
for i in range(notify_system.Count()):
notifier = notify_system.ByIndex(i) # get the lx.object.Notifier
name = notify_system.NameByIndex(i) # get the str name for the Nofifier
# attempt getting arguments for the notifier,
try:
@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
@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 / 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"
)
View modo_selection_mode.py
# python
import lx
def get_selection_mode():
""" Get the current selection mode
:rtype: int