Notifications
Clear all

[Closed] Adding interactive preview to script

I’m fairly new to scripting and this might have been covered somewhere else on this forum but I haven’t been able to locate it yet. What I’m looking to do is like what the EditPoly Connect operation has and that is an interactive preview so when you adjust spinners you can visually see what is going to happen.

The script that I’ve (co-)written uses polyOp commands to get faces, vertices and then performs a polyOp.slice command to split the faces based on where the code determines to cut them. Now I’d like the user to be able to visualise where the cutting takes place before they apply the change.

The way I thought this could be done is either by using the previewBegin/previewAccept/previewCancel methods of the EditablePoly object. However when I’ve tried to implement it using this means of previewing it didn’t work and I assumed it cannot be done using the polyOp object methods.

The other option was placing an undo block around the code and calling an undo everytime the spinner is changed, only allowing the changes to remain when the user presses the apply button.

So I guess what I’m asking is, what do you seasoned veterans do to allow for interactive reviewing? Should I be able to use the previewXX methods to revert any changes made using polyOp methods on an EditablePoly?

Any help in this matter would be greatly appreciated. Just so you know I have searched through the maxscript help and also google searched for the answer but no luck in finding anything relevant.


…++|| raster ||++…

4 Replies

i may be bumping a little older thread here but i’d verry much like to have an answer to this too as i searched but couldn’t find.

i’m trying to create a scripted modifier plugin that changes the topology of the object it’s attached to. but i want it to work like a modifier wich means it should only affect the object at a certain “level” and undo itself when it is removed no matter what has been changed underneath it. as i cant assign a trimesh to the .mesh prop of the obj wich has mods on it im a little lost here :banghead:

accessing the object is not a problem, but changing it (removing verts, adding edges) in the “way a modifier does” sorta is.

Hi,
This is kind of complicated to do.
either you can do the operation and implement an undo system
or you can use gw commands to ‘draw’ on the mesh.

Have a look @ the wonderfull script from enrico:
look for IC.PolySplitRing

http://illusioncatalyst.com/mxs.php

hope this gets you going

that works well when remapping the edges thx

but i also edit geometry… in a modifier thats the problem. if i save the trimesh underneath you can change it, ect just fine but once i edit something underneath that mod i got an invalid mesh saved and no event that “told me so”
so how in the world do the standart modifiers do their gemetry-based preview? 🙁

Hi Raphael, here start my almost clueless explanation (well, maybe not so) take it as a hint. I guess the system starts from the current state of the object and applys the extrude/chamfer/connect/… reaching a second state. Even if you’re in a kind of preview mode, the one you got is the actual object state, already modified by the operator. As a matter of fact the Modifier Stack takes into account the “preview” geometry, like when you got a TurboSmooth on top and enable “Show end result” you can see the smoothed extrusion while changing parameters.

If you press Apply, operation is “closed” and another one starts on the new selection, while if you Cancel, the system fetches the last state before current operation, performing a sort of Undo, like Zbuffer said. (It should be something a little different, like not creating a new PointRestore Object.)

When you change a parameter in the preview floater, like the pinch or slide spinners in the options floater for connect, the system calculates the “preview” state every time starting from the stored state and applying the operation with current parameters.

I’m quite sure it’s a bit more complicated (and smarter) than this, like theHold system is in the SDK, anyway this is how I’d start coding it when trying to get a preview for a command. Back to the question, I guess MaxScript doesn’t give so much flexibility to deal with something like this with stable and quick feedback, so I second the idea to use a graphic preview and apply the modification with desired parameeters once only.

  • Enrico