Skip to content

Instantly share code, notes, and snippets.

def combineFaces(faces, edgesToDelete):
""" This is where the edge deletion actually happens
Turn a group of connected faces into a new polygon
"""
# TODO
pass
def deleteEdges(counts, connects, edgesToDelete):
@dseeni
dseeni / 0instructions.md
Created July 7, 2022 04:02 — forked from caseywatts/0instructions.md
Easily fill out web forms using data from a spreadsheet using this bookmarklet.

Other gists & tricks: http://caseywatts.com/gists-and-tricks

To set this up, paste the code below into the "location" of a bookmark. Make sure it starts with "javascript:", some browsers strip this out when you paste.

  1. Find the "name" of each form element you want to put data into. You can find the "name" by right clicking on the form box and "inspecting" it.
  2. By using a spreadsheet, create a set of urls with the data you want to input. Example: variablename1 is the "name" of the form field. "value1" is the value you want to put into the box.www.website.com/page.html?variablename1=value1&variablename2=value23. Navigate to that custom URL4. Click the bookmarklet. Voila!
@dseeni
dseeni / matrix-dimension.js
Created May 28, 2022 01:05 — forked from srikumarks/matrix-dimension.js
Getting the dimensions of a multidimensional JS array.
// Assumes a valid matrix and returns its dimension array.
// Won't work for irregular matrices, but is cheap.
function dim(mat) {
if (mat instanceof Array) {
return [mat.length].concat(dim(mat[0]));
} else {
return [];
}
}
@dseeni
dseeni / selectNgons.mel
Created June 26, 2021 07:31 — forked from dy-dx/selectNgons.mel
Maya script that selects all visible non-quad faces in the scene.
{
// Make sure we're in object mode, otherwise some currently selected faces can mess this up.
// Need to switch on component mode first to make this work in all cases.
changeSelectMode -component;
changeSelectMode -object;
// Select all face components
select -r `listTransforms "-type mesh -visible"`;
PolySelectConvert 1;
@dseeni
dseeni / gist:304c653ab972e27aeb2244d14cf306ad
Created March 23, 2021 17:15 — forked from mazbox/gist:2724338
line-line intersection in 3d for openframeworks
ofVec3f utils::lineLineIntersection(ofVec3f p1, ofVec3f p2, ofVec3f p3, ofVec3f p4) {
ofVec3f pa, pb;
utils::lineLineIntersectSegment(p1,p2,p3,p4,pa,pb);
return (pa+pb)/2.f;
}
// from the bourkster.
bool utils::lineLineIntersectSegment(ofVec3f p1, ofVec3f p2, ofVec3f p3, ofVec3f p4, ofVec3f &pa, ofVec3f &pb) {
@dseeni
dseeni / markingMenu.py
Created March 12, 2021 12:08 — forked from vshotarov/markingMenu.py
Example of a custom marking menu in Maya, scripted in Python.
'''A simple example of a custom marking menu in Maya. The benefits of doing it this way with Python are that
it is very flexible and easily maintainable. Additionally, you can keep it in a version control system.
This file is used for demonstration purposes, to be followed along with in this blog post
http://bindpose.com/custom-marking-menu-maya-python/
'''
import maya.cmds as mc
@dseeni
dseeni / kdtree.py
Created March 11, 2021 21:05 — forked from tompaton/kdtree.py
Python kd-tree spatial index and nearest neighbour search
#!/usr/bin/env python
# kd-tree index and nearest neighbour search
# includes doctests, run with: python -m doctest kdtree.py
class KDTree(object):
"""
kd-tree spatial index and nearest neighbour search
http://en.wikipedia.org/wiki/Kd-tree
"""
@dseeni
dseeni / 2d_center_on_object_api_1.0.py
Created March 6, 2021 18:24 — forked from Liametc/2d_center_on_object_api_1.0.py
Center maya camera 2D pan/zoom on object using python api 2.0
from maya import OpenMaya
# create selection
sel = OpenMaya.MSelectionList()
sel.add("locator1")
sel.add("camera1")
# get dag paths
loc_dag = OpenMaya.MDagPath()
sel.getDagPath(0, loc_dag)
@dseeni
dseeni / check_poly_normals.py
Created March 6, 2021 18:24 — forked from Liametc/check_poly_normals.py
Check polygon normals in maya using python api 2.0
import maya.api.OpenMaya as om
import maya.cmds
import time
def is_normal_reversed(poly, mesh):
"""
Check the normal faces in or out of the model by doing a simple ray cast and
count results. Evens face out, odds face in.
#F. Hiba, C. Mendes, B. Lefebvre, P. Hubert
import maya.api.OpenMaya as om
import maya.cmds as cmds
from math import radians, degrees, sin, cos
from random import gauss, random, uniform, shuffle
from copy import copy
#4 utilities function related to transformations
#give the quaternion corresponding to the rottion from vector 1 to vector 2