Message 1 of 17
Convert any shape to Editable Spline
Not applicable
02-07-2017
09:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to convert a Shape object (Line for example) to an Editable Spline in C#.
Here's my code :
public int ConvertToEditSpline(IINode node)
{
if (node.ObjectRef.SuperClassID != SClass_ID.Shape)
return -1;
if (node.ObjectRef.ClassID.PartA == (uint)BuiltInClassIDA.SPLINESHAPE_CLASS_ID)
return 0;
IObjectState objstate = node.ObjectRef.Eval(MaxInterfaces.Ip.Time);
IShapeObject obj = objstate.Obj as IShapeObject;
Console.WriteLine(obj.CanConvertToType(MaxUtils.SplineShapeClassID).ToString());
// Print "1", so it can convert the object.
ISplineShape newSpline = obj.ConvertToType(MaxInterfaces.Ip.Time, MaxUtils.SplineShapeClassID) as ISplineShape;
// newSpline is null...
if (newSpline == null)
return -1;
node.ObjectRef = newSpline.CollapseObject;
return 0;
}As you can, everytime I try to convert a ShapeObject to SplineShape, it returns null.
How can I solve this ?
Thank you.

