[Closed] An old question
I found a new way, but it’s not stable.Don’t know what went wrong.Whether a Notify Dependents is required
//obj is Line
int t = g.COREInterface.Time;
ISplineShape ss = g.SplineShape.Create();
IShapeObject spl = (IShapeObject)obj;
IBezierShape bz = ss.Shape;
spl.MakeBezier(t, bz);
node.ReplaceReference(1, ss, true);
I think it is a bit overkill to make a bezier out of a linear shape, but if you don’t want to mess with the edit_spline modifier it might be better. In other cases simple conversion with ConvertToType should work just fine.
You previously asked about undo/redo implementation in c#. Did you manage to make it work for shapes conversion?
... https://forums.cgsociety.org/t/how-can-i-write-a-undo-redo-using-c/2069476/8
theHo.Begin();
theHo.Put(new SRYRest(handle, all3dLines));
// convert line to splineshape
theHo.Accept("SRYundo");
theHo.Suspend();
The Undo/Redo is not particularly urgent for me, The Line converted to Spline shape is special importance thing for me .If a line is with other Modifiers,I can’t convert it in this state.Because the modifiers will disappear when I use to Collapse Node,That’s what I don’t want to see.Isn’t there an easier way?Why is my new method a bit overkill?Can you go into more detail?I also feel its instability, do not know what the problem is.ths
in this case ReplaceReference is certainly a solution
Actually, I don’t know what edit spline mod does to the line object for it to become convertible to splineshape, perhaps my assumption about makebezier being an overkill (in terms of performance) is wrong.
It is hard to tell why is it instable in your case. Try to call notify dependents on splineshape and see if it makes any difference. Although I couldn’t find much examples across sdk files where this call was needed. It could be something else.
Afaik, you can set a breakpoint where needed, compile c# dll, put in bin/assemblies, start max, attach to the process and then you’ll be able to debug your code. I did that only once, so can’t provide any help or advice here.
When it comes to low level programming for max it is preferable to switch to C++ cause it is way simpler to develop and debug.