'TYTYTYTYTYTYTYTYTYTYTYTYTYTYTYTTYTYTYTYTTYTYTYTYTYTTYTYTYYTYTTYTYTYYTYTTYTYTY
'
'Name: TY_Vertex_Tool
'Version: 1.0
'Last Modified: 2003/04/01
'
'Description:Add middle vertices/Remove vertices tool similar to SI3D.
'
'Author: Takeshi Yamada (Born Digital,inc.)
'Contact: takeshi-y@borndigital.co.jp
'
'(c) Copyright April 2003 Takeshi Yamada
'
'TYTYTYTYTYTYTYTYTYTYTYTYTYTYTYTTYTYTYTYTTYTYTYTYTYTTYTYTYYTYTTYTYTYYTYTTYTYTY
'
'USAGE:This script will make you Add Middle Vertices/Remove Vertices similar to SI3D [Model Module] > Polygon > Vertex command.
'
'(1) Select Polygon Objects.
'
'(2) Run this sctipt.
'
'(3) Choice Add Mode or Remove Mode by clicking Left Mouse Bottan or Middle Mouse Bottan respectively.
'
'(4) If you choiced Add Mode, then pick any edges which you want to split by Left or Middle Mouse Bottan.
'
'(5) If you choiced Remove Mode, then pick any vertices which you want to collapose by Left or Middle Mouse Bottan.
'
'(6) If you want to change carrnt mode, then click Right Mouse Bottan and return to (3)
'
'(7) If you want to abort the script, then double click Right Mouse Bottan or push Esc key.
'
'
'Note:Recommend to activate point visibility.
'
'

Option Explicit
TY_Vertex_Tool
'---------------------------------------------
' TY_Vertex_Tool
'---------------------------------------------

Sub TY_Vertex_Tool()

Dim PosX, PosY, PosZ
Dim iSelBtn, iSelBtn2, iSelBtn3
Dim oEdge, oPoint


do


PickPosition "Add Middle Vertex Tool","Remove Vertex Tool", PosX, PosY, PosZ, iSelBtn


if iSelBtn = 1 then
LogMessage "Add Vertex on the middle point of picked edge."
SelectFilter "Edge"


do

PickElement "Edge","Pick Edges to Add Middle Vertex", "Pick Edges to Add Middle Vertex", oEdge, iSelBtn2


if iSelBtn2 = 1 then
LogMessage "Add middle Vertex to" & oEdge
SplitEdge oEdge, 50, False, True, siPersistentOperation


elseif iSelBtn2 = 2 then
LogMessage "Add middle Vertex to" & oEdge
SplitEdge oEdge, 50, False, True, siPersistentOperation


elseif iSelBtn2 = 0 then
LogMessage "Cancel- Add Middle Verteis"


exit do


else
LogMessage "Error"


exit do


end if

loop

elseif iSelBtn = 2 then
LogMessage "Remove a picked Vertex."
SelectFilter "Point"

do

PickElement "Point","Pick Vertices to Remove", "Pick Vertices to Remove", oPoint, iSelBtn3


if iSelBtn3 = 1 then
LogMessage oPoint & " Remove Vertex"
ApplyTopoOp "Collapse", oPoint, siUnspecified, siPersistentOperation


elseif iSelBtn3 = 2 then
LogMessage oPoint & " Remove Vertex"
ApplyTopoOp "Collapse", oPoint, siUnspecified, siPersistentOperation


elseif iSelBtn3 = 0 then
LogMessage "Cancel- Remove Vertices"


exit do


else
LogMessage "Error"


exit do


end if

loop

elseif iSelBtn = 0 then
LogMessage "Cancel"


exit do


else
LogMessage "Error"


exit do


end if


loop


SelectFilter "object"


End Sub