Notifications
Clear all
[Closed] Modifying SplineShapes from DotNet
Dec 06, 2015 1:13 am
Greetings ALL.
I’m having trouble modifying splines using Autodesk.Max.dll. I can’t seem to get a cast working from IShapeObject to ISplineShape. The contained object is the correct ClassID for a splineShape, but I only get null returned when I attempt the cast.
I get similar results when I try .ConvertToType(TIME, CLASS_ID)
Tried a few other casts and accessors, as well. I’m sure I must be glazing over the answer in the SDK docs. It’s gotta just be one of those one line simple solutions that’s eating hours.
/
/ create LiftLines
for (var c = 0; c < AgxRopes.Count; c++)
{
var node = Ip.GetINodeByHandle((uint)ghostLiftlines[c]);
var refWinch = AgxWinches[c];
var precision = 10;
var pulledInLength = refWinch.getPulledInWireLength();
var RopeLength = AgxRopes[c].getCurrentLength(false);
IObjectState os = node.ObjectRef.Eval(Ip.Time);
var obj = os.Obj;
IShapeObject sShape = obj as IShapeObject;
ISplineShape ssShape = sShape as ISplineShape; // returns null :(
var sBez = ssShape.Shape;
var s3D = sBez.GetSpline(0);
for (int v = 0; v < precision; v++)
{
var pt = AgxRopes[c].findPoint(pulledInLength + v * (RopeLength / precision));
s3D?.SetKnot(v, Global.SplineKnot.Create(0, 0, Global.Point3.Create(pt.x, pt.y, pt.z), Global.Point3.Create(0, 0, 0), Global.Point3.Create(0, 0, 0),
-1, -1, -1, -1, -1, -1, -1, -1, -1, 0));
}
s3D.ComputeBezPoints();
sBez.UpdateSels(true);
sShape.InvalidateGeomCache();
GhostLines.Add(node);
}