Solved! Go to Solution.
Solved by dswahn. Go to Solution.
UpdateShape would be the right one if you were using addKnot+setKnotPoint but it looks like you're using splineOps. You could try some of the SDK methods like InvalidateGeomCache. In mxs, it could look like this:
iGlobal = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
obj = iGlobal.Animatable.GetAnimByHandle (getHandleByAnim $.baseObject)
if isProperty obj #InvalidateGeomCache do obj.InvalidateGeomCache()
But given that it looks more like the command mode of the splineOps isn't finished properly, it might be enough to call some of the 'max' commands when you're finished to force command mode change, for example
max select
Unfortunately the obj.InvalidateGeomCache() approach returns undefined.
I cannot verify whether this works or not.
The return type is void so yeah, it will only return undefined. You should be able to test if the outline works after calling it or not.
Without some sample code to reproduce the issue, I can't really give you a better advice.
After trying with just splineOps.startInsert $ on a spline object I realized that the bug does not happen.
I pinpointed the issue to being the max select command. If I remove max select from my code I can perform an Outline operation as expected.
So while the max select helps me cancel the Insert operation, it somehow messes up the content of the spline in the process, so any operation applied after the Insert results in the spline state before the Insert.
At least the problem has been pinpointed, but the question is how to solve it?
I kind of need the max select in order to cancel the Insert operation. Otherwise the user needs to right-click two times which is a bit annoying...
Still no code to reproduce so this is my last contribution here. Since all splineOps do (and why I avoid using them at all) is that they push buttons in the UI, you can do the same and push button in the UI to deactivate it.
(
local iGlobal = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
local cpHWnd = iGlobal.UtilGetCoreInterface.CommandPanelRollup.HWnd
local cpChildren = windows.getChildrenHWnd cpHWnd
local insertHWnd = for child in cpChildren
where UIAccessor.getWindowResourceID child[1] == 1042 do
exit with child[1]
if isKindOf insertHWnd Number do UIAccessor.pressButton insertHWnd
)
I'm sorry if I have not provided any code, while I was putting together an example of the code I realized another important thing that solved the issue. I had put max select within an undo off(), and apparently this confused the process.
The thing is that I put the process of deleting the temporary grid outside the undo context so that if you undo this temporary grid won't pop back into existence. All I had to do was to change this:
undo off
(
activeGrid = oldGrid
delete tempGrid
max select
)
To this:
undo off
(
activeGrid = oldGrid
delete tempGrid
)
max select
Also the reason why I use splineOps.startInsert is because it provides simple undo for the changes you make to the spline. There is a long-persisting bug or behaviour in max where changes to splines made by maxscript doesn't produce an undo context, meaning you cannot undo the changes. Using splineOps.startInsert gives you that undo context.
I can however conclude that the problem has been solved.
Thanks for the input @Swordslayer !
@dswahn wrote:
There is a long-persisting bug or behaviour in max where changes to splines made by maxscript doesn't produce an undo context, meaning you cannot undo the changes. Using splineOps.startInsert gives you that undo context.
Call replaceInstances $.baseObject $.baseObject after your operation to get an undo record with spline changes.
Thank you. I read previously that one can make the changes on a clone of the spline, instance that to the original object (and delete the clone) under the same undo to force an undo, but your suggestion looks obviously simpler.
I will try it.
Thanks again.
Can't find what you're looking for? Ask the community or share your knowledge.