[Closed] Insert vertex
Hello everyone,
I am in need with a little script if someone can help me. It is about inserting a vertex on an selected edge by simply pressing a shortcut. I know there is the insert vertex button in the command panel but I do not want to switch to that tool but only inserting the vertex by pressing a button/shortcut.
Thank you.
dare I ask why you don’t wish to enter that mode?
Although the code behind inserting the vertex is nicely abstracted (macro recorder reports it), a lof of the internals (determing which edge you’re hovering your mouse over, for example) are not.
The reason was that I wanted to place the vertex right in the middle of the edge…but if it is so complicated making this script…then no problem, I’ll try using default mode…I just was wondering if it was possible making a script doing this thing
a-ha
Your explanation is the reason I ask – the script becomes a lot easier when the parameters are narrowed down.
for o in (getCurrentSelection()) do (
if (isProperty o #insertVertexInEdge) then (
for edge in o.selectedEdges do (
o.insertVertexInEdge edge.index 0.5 select:true
)
)
)
Basic explanation of the code…
It loops over the scene’s current selection of objects.
For each of those objects, it checks whether the object supports the “insert vertex” functionality.
If it does, then it loops over each selected edge in that object.
And for each selected edge, it inserts the vertex exactly in the middle (0.5 = 50% along the length of the eddge), and selects the new vertex.
You can drag&drop this code to a button to make a macroscript out of it, assign it to a hotkey combination, etc.
This is what I was looking for…it works and it works great…men you are awesome…thank you thousand times.