Im trying to add the ability to add a vert to the middle of an edge while in an Edit_Poly modifier, but it's not working out so well. Using the DivideEdge function it'll split the edge, but the new vert wont be selectable. This is what I'm doing after selecting the edge:
varEdjIndex = ((($.Edit_Poly.getSelection #Edge) as array)[1])
$.modifiers[#Edit_Poly].DivideEdge varEdjIndex 0.5
Is this a glitch or am I doing something wrong?
Replies
As a general suggestion do not rely on Modifiers name with the syntax modifiers[#name], because even if it's a remote case, the user can change it, or there can be more modifiers with the same name. Getting them by index modifiers[1] is a bit better but still unsafe, because stack order can change. Better to verify modifier class before storing it in a variable that is tied to such modifier, something like: if (classOf modifiers[1] == Edit_Poly) do ( myModVar = modifiers[1] ), assuming you know modifiers[1] is the one you're looking for. Otherwise you can use: modPanel.getCurrentObject() to get currently active modifier then test its class.
How would you go about getting a modifiers actual name then? Using modPanel.getCurrentObject() it'd return the modifier class:name, and with classOf you'd obviously get just the class , but what about getting just the name, as I assume that's what you're saying would be the most safe/correct method? Or would it be possible to see how you'd change this to be more correct / safe?:
Store its single elements in a variable like:
local theNode = Selection[1]
Or if you need the whole array make a static copy like:
local theSelArray = Selection as Array
Here is the code the way I'd write it, if meant to work on the currently active Edit Poly Modifier.