Skip to content

Instantly share code, notes, and snippets.

@Swordslayer
Swordslayer / addModifierWithoutNode.ms
Created April 27, 2022 17:06
How to to object instance without creating a scene node.
(
local iGlobal = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
local boxObj = createInstance Box
local turboObj = TurboSmooth iterations:3
local derObj = iGlobal.CreateDerivedObject (iGlobal.Animatable.GetAnimByHandle (getHandleByAnim boxObj))
derObj.AddModifier (iGlobal.Animatable.GetAnimByHandle (getHandleByAnim turboObj)) undefined 0
local objState = derObj.Eval currentTime.ticks 0
-- just to show the result, let's create some object with the snapshot of the stack as its baseobject
Plane baseObject:(getAnimByHandle ((iGlobal.Animatable.GetHandleByAnim objState.Obj asDotNetObject:on).ToUInt64())) isSelected:on
@Swordslayer
Swordslayer / openPathDeformScaleCurve.ms
Created April 11, 2022 13:41
Open the Scale Curve Editor window of the new Path Deform modifier.
(
fn collectButtons widget &buttons =
(
local children = widget.children()
for i = 0 to children.count - 1 do
(
if children[i].__class__.__name__ == "QPushButton" do append buttons children[i]
collectButtons children[i] &buttons
)
)
@Swordslayer
Swordslayer / selectNormalsBorderEdges.ms
Last active March 3, 2022 15:46
Select edges across vertices with multiple explicit normals. For imported CAD geometry, these usually correspond to the original iso lines.
(
local compilerParams = dotNetObject "System.CodeDom.Compiler.CompilerParameters" #(
getDir #maxRoot + "\bin\assemblies\Autodesk.Max.Wrappers.dll",
getDir #maxRoot + "Autodesk.Max.dll")
compilerParams.GenerateInMemory = true
local compilerResults = (dotNetObject "Microsoft.CSharp.CSharpCodeProvider").CompileAssemblyFromSource compilerParams #(
"using System;
using Autodesk.Max;
using Wrappers = Autodesk.Max.Wrappers;
@Swordslayer
Swordslayer / SetDataChannelCurve.ms
Created February 11, 2022 15:22
Setting points of the DataChannel modifier curve control.
(
local obj = Sphere segs:64 isSelected:on
local dataChannel = DataChannelModifier()
addModifier obj dataChannel
local iGlobal = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
local CURVEP_BEZIER = bit.shift 1 0
local CURVEP_CORNER = bit.shift 1 1
fn convertPoint pt =
@Swordslayer
Swordslayer / SetPainterCurve.ms
Last active February 11, 2022 16:35
Setting points of the painter interface curve
(
local iGlobal = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
local refTargID = (dotNetClass "Autodesk.Max.SClass_ID").RefTarget
local painterID = iGlobal.Class_ID.Create PainterInterface.classID[1] PainterInterface.classID[2]
local painterID_V5 = (dotNetClass "System.Enum").ToObject (dotNet.getType (dotNetClass "Autodesk.Max.InterfaceID")) (dotNetObject "System.Int32" painterID.PartB)
local painterRefTarg = (iGlobal.UtilGetCOREInterface.CreateInstance refTargID painterID).GetInterface painterID_V5
local painterMarshaler = (dotNetClass "Autodesk.Max.Wrappers.CustomMarshalerIPainterInterface_V5").GetInstance ""
local painter = painterMarshaler.MarshalNativeToManaged painterRefTarg.NativePointer
local curve = painter.FalloffGraph
@Swordslayer
Swordslayer / MXSQtSample.ms
Last active May 12, 2021 09:46
Using Qt UI with scripted plugins.
plugin simpleManipulator MXSQtSample
name:"MXSQtSample" category:"Manipulators"
classID:#(0x76d22fb1, 0x190d5d2d)
(
parameters main rollout:params
(
radius type:#worldUnits default:10
on radius set val do if not loading and this.params.isDisplayed do
(
this.params.dial.blockSignals on --> prevent recursive calls