Skip to content

Instantly share code, notes, and snippets.

@EricTRocks
Created September 16, 2016 21:31
Show Gist options
  • Save EricTRocks/e5105affcfd6726bb0ef2f5d3b043fbd to your computer and use it in GitHub Desktop.
Save EricTRocks/e5105affcfd6726bb0ef2f5d3b043fbd to your computer and use it in GitHub Desktop.
Create a Spline with Sub-Curves in 3dsMax 2017
import MaxPlus
p1 = MaxPlus.Point3(0, 0, 0)
p2 = MaxPlus.Point3(0, 30, 0)
p3 = MaxPlus.Point3(10, 30, 0)
p4 = MaxPlus.Point3(10, -20, 0)
obj = MaxPlus.Factory.CreateShapeObject(MaxPlus.ClassIds.SplineShape)
shape = MaxPlus.SplineShape__CastFrom(obj)
bezier = shape.GetShape()
bezier.NewShape()
spline = bezier.NewSpline()
spline.AddKnot(MaxPlus.SplineKnot(MaxPlus.SplineKnot.AutoKnot, MaxPlus.SplineKnot.CurveLineType, p1, p1, p1))
spline.AddKnot(MaxPlus.SplineKnot(MaxPlus.SplineKnot.AutoKnot, MaxPlus.SplineKnot.CurveLineType, p2, p2, p2))
spline.AddKnot(MaxPlus.SplineKnot(MaxPlus.SplineKnot.AutoKnot, MaxPlus.SplineKnot.CurveLineType, p3, p3, p3))
spline.AddKnot(MaxPlus.SplineKnot(MaxPlus.SplineKnot.AutoKnot, MaxPlus.SplineKnot.CurveLineType, p4, p4, p4))
spline.SetClosed(True)
p1 = MaxPlus.Point3(0, 0, 10)
p2 = MaxPlus.Point3(0, 30, 10)
p3 = MaxPlus.Point3(10, 30, 10)
spline2 = bezier.NewSpline()
spline2.AddKnot(MaxPlus.SplineKnot(MaxPlus.SplineKnot.CornerKnot, MaxPlus.SplineKnot.LineLineType, p1, p1, p1))
spline2.AddKnot(MaxPlus.SplineKnot(MaxPlus.SplineKnot.CornerKnot, MaxPlus.SplineKnot.LineLineType, p2, p2, p2))
spline2.AddKnot(MaxPlus.SplineKnot(MaxPlus.SplineKnot.CornerKnot, MaxPlus.SplineKnot.LineLineType, p3, p3, p3))
bezier.UpdateSels()
bezier.InvalidateGeomCache()
node = MaxPlus.Factory.CreateNode(obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment