Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# Transfer the selected weight maps from the primary (first selected) mesh to all other active (selected) meshes (map is created if required).
# Transfer happens via vertex index, if the two meshes have different vertex counts nothing will happen.
# If no weight maps are selected, all are transferred.
# Optional target map argument will cause the first selected weight map found on the primary mesh to be transferred to a weight map of the given name on the active mesh (map is created on the active mesh if required).
# NOTE: With the optional map argument given, only one map will be transferred.
import lx
import lxifc
#!/usr/bin/env python
import lx
import lxifc
import lxu.command
class DeleteMaps (lxifc.Visitor):
def __init__ (self, meshmap):
self.meshmap = meshmap
@Farfarer
Farfarer / Cable.cs
Created July 5, 2016 15:45
Catenary curves in Unity. Creates a catenary curve between two points with a given amount of slack. http://farfarer.com/temp/unity_cables.png
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.EventSystems;
[System.Serializable]
public class CableCurve {
[SerializeField]
Vector3 m_start;
@Farfarer
Farfarer / createBBOX.py
Created July 13, 2016 08:46
AABB and AACyl creation for MODO.
#!/usr/bin/env python
# Uses Smallest Enclosing Circle code which is:
# Copyright (c) 2014 Nayuki Minase
# http://nayuki.eigenstate.org/page/smallest-enclosing-circle
import lx
import lxifc
import lxu.command
import lxu.select
@Farfarer
Farfarer / combineVMaps.py
Created July 13, 2016 17:16
Install to "lxserv" directory in your script directory. Restart MODO. Use it by calling the command "ffr.combinevmaps"
#!/usr/bin/env python
import lx
import lxifc
import lxu.command
import lxu.select
default_type = 'weight'
default_source_name = 'Weight'
default_target_name = 'Weight'
@Farfarer
Farfarer / deleteNamelessVMaps.py
Created July 15, 2016 10:16
Install to "lxserv" directory in your script directory. Restart MODO. Use it by calling the command "ffr.deleteNamelessVMaps".
#!/usr/bin/env python
import lx
import lxifc
import lxu.command
class DeleteMaps (lxifc.Visitor):
def __init__ (self, meshmap):
self.meshmap = meshmap
@Farfarer
Farfarer / getSetSceneTag.py
Created October 5, 2016 16:21
Set and get the value of a tag that's stored with the scene in MODO.
# !/usr/bin/env python
import lx
import lxu
import lxu.select
def setSceneTag (tagID, tagValue)
if isinstance (tagID, basestring):
if len (tagID) != 4:
lx.out('Tag ID must be 4 characters long!')
@Farfarer
Farfarer / clampRGBA.py
Created October 13, 2016 14:31
Clamps RGBA vertex map values to the 0-1 range. Stick this into a folder called "lxserv" in your user scripts directory. Restart MODO. Use "ffr.clampRGBA" to run the command.
#!/usr/bin/env python
import lx
import lxifc
import lxu.command
def vclamp (a):
b = list(a)
beenClamped = False
for x in xrange(4):
@Farfarer
Farfarer / expandByMaterial.py
Created November 16, 2016 17:50
Expands current polygon selection by material ID.
# Run with `ffr.expandByMat`, it will expand the current polygon selection by the material ID of the current polygon selection.
#
# An optional argument, `materialID` will expand only by a given material ID, e.g.
# `ffr.expandByMat "Default"`
#!/usr/bin/env python
import lx
import lxu.command
import lxifc
@Farfarer
Farfarer / polysByIsland.py
Created December 13, 2016 15:03
MODO pyAPI - Get the polygon IDs of each "island" of polygons in the active layers.
#!/usr/bin/env python
import lx
import lxu.command
import lxifc
class SetMarks (lxifc.Visitor):
def __init__ (self, acc, mark):
self.acc = acc
self.mark = mark