Skip to content

Instantly share code, notes, and snippets.

View tpoveda's full-sized avatar
🏠
Working from home

Tomás Poveda tpoveda

🏠
Working from home
View GitHub Profile
@tpoveda
tpoveda / GetSwivelTargetPosition.ms
Last active August 23, 2017 12:54
Function that calculates a correct swivel target position for a IKHI solver
-- Function that calculates a correct swivel target position for a IKHI solver
-- The returned position will not produce any kind of pop-up when setting the swivel target of an IKHI solver
-- NOTE: All the bones MUST be on the same plane
function GetSwivelTargetPosition boneA boneB boneC pvDst:1.0 createLoc:false =
(
boneAPos = boneA.position
boneBPos = boneB.position
boneCPos = boneC.position
-- Get initial vectors
@tpoveda
tpoveda / SelectedEdgeLoop.py
Created February 18, 2018 01:15
Select edge loops from selected edge - MEL
import maya.mel as mel
mel.eval('SelectEdgeLoopSp;')
@tpoveda
tpoveda / SelectedEdgeLoopPyMEL.py
Created February 18, 2018 01:16
Select edge loops from selected edge - PyMEL
from pymel.core import runtime
runtime.SelectEdgeLoopSp()
@tpoveda
tpoveda / ControlView.py
Created February 18, 2018 01:17
Drag & Drop in QGraphicsView (PyQt - PySide)
from Qt import QtCore as qc
from Qt import QtGui as qg
from Qt import QtWidgets as qw
class ControlView(qw.QGraphicsView):
"""
Base class to create the control view
"""
@tpoveda
tpoveda / FreezeTransforms.ms
Created February 18, 2018 01:19
FreezeTransforms programatically in 3ds Max - MaxScript
fn FreezeTransforms obj =
(
local curObj = obj
if classOf curObj.rotation.controller != Rotation_Layer do
(
-- Freeze rotation
curObj.rotation.controller = Euler_Xyz()
curObj.rotation.controller = Rotation_List()
curObj.rotation.controller.available.controller = Euler_Xyz()
@tpoveda
tpoveda / MayaSnapPivot.py
Last active June 19, 2018 09:00
Snap source object pivot position to the world position of the target object
import maya.cmds as cmds
def snap_pivot(source=None, target=None):
sel = cmds.ls(sl=True)
source = sel[0] if not source else source
target = sel[1] if not target else target
pivot = cmds.xform(target, query=True, pivots=True, worldSpace=True)
cmds.xform(source, worldSpace=True, pivots=(pivot[0], pivot[1], pivot[2]))
snap_pivot()
@tpoveda
tpoveda / FramelessDialog.ms
Last active July 29, 2020 09:54
Creates a frameless MaxScript dialog with maximize/minimize/close buttons
rollout FramelessRollout "Frameless Rollout" width:210 height:25
(
local wndHandle
local WM_SYSCOMMAND = 0x112
local SC_MINIMIZE = 0xf020
local SC_MAXIMIZE = 0xf030
local SC_RESTORE = 0xf120
button min_btn "Minimize" pos:[4,4] width:64 height:20
@tpoveda
tpoveda / PySideScrollbarHandleSize.py
Last active June 19, 2018 09:00
Get handle size of QScrollBar
opt = QStyleOptionSlider()
self.view.horizontalScrollBar().initStyleOption(opt)
style = self.view.horizontalScrollBar().style()
handle = style.subControlRect(style.CC_ScrollBar, opt, style.SC_ScrollBarSlider)
sliderPos = handle.center()
@tpoveda
tpoveda / MaxPlusModDeps.py
Last active June 19, 2018 08:59
MaxPlus - Get modifier dependant nodes
import MaxPlus
def get_scene_nodes():
"""
Return all nodes in current scene
:return: generator<INode>
"""
stack = [MaxPlus.Core.GetRootNode()]
while stack:
@tpoveda
tpoveda / MaxPlusAllSceneNodes.py
Last active June 19, 2018 09:05
MaxPlus - Get all scene nodes
import MaxPlus
def get_scene_nodes():
"""
Return all nodes in current scene
:return: generator<INode>
"""
stack = [MaxPlus.Core.GetRootNode()]
while stack: