I want to use addoptionlist in getobject class. But It seems useless. see the code below. can you tell me where am I wrong. Thank you in advance!
Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As Rhino.Commands.RunMode) As Rhino.Commands.Result
Const geometryFilter As ObjectType = ObjectType.Brep
Dim rc As Rhino.Commands.Result = Rhino.Commands.Result.Failure
Dim go As New GetObject()
Dim opbl As New OptionToggle(False, "否", "是")
'Dim cutmode1 As New OptionToggle(True, "否", "是")
'Dim cutmode2 As New OptionToggle(False, "否", "是")
go.SetCommandPrompt("请选取被当前平面切割的物件(Select Objects to cut)")
go.GeometryFilter = geometryFilter
go.AddOptionToggle("是否保留原物件", opbl)
Dim listIndex As Integer = 1
Dim opList As Integer = go.AddOptionList("保留侧(Side to reserve)", New String() {"两侧(Both side)", "Z轴正侧(Z aixs side)", "Z轴负侧(-Z aixs side"}, listIndex)
'go.AddOptionToggle("保留Z轴正向物件", cutmode1)
'go.AddOptionToggle("保两侧切割物件", cutmode2)
go.GroupSelect = True
go.SubObjectSelect = True
go.EnableClearObjectsOnEntry(False)
go.EnableUnselectObjectsOnExit(False)
go.DeselectAllBeforePostSelect = False
'Dim gop As New Rhino.Input.Custom.GetOption()
'gop.AddOptionList("保留侧(Side to reserve)", New String() {"两侧(Both side)", "Z轴正侧(Z aixs side)", "Z轴负侧(-Z aixs side"}, listIndex)
While True
Dim res As GetResult = go.GetMultiple(1, 0)
If res = GetResult.[Option] Then
go.EnablePreSelect(False, True)
If go.OptionIndex() = opList Then
listIndex = go.[Option]().CurrentListOptionIndex
End If
Continue While
ElseIf res <> GetResult.[Object] Then
Return Result.Cancel
Else
End If
'If go.ObjectsWerePreselected Then
' go.EnablePreSelect(False, True)
' Continue While
'End If
Exit While
End While
Dim Mcutterplane As Plane = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane
Dim recutterplane As New Plane(Mcutterplane.Origin, Mcutterplane.YAxis, Mcutterplane.XAxis)
Dim Mreflist As New List(Of ObjRef)
MsgBox(listIndex)
For i As Integer = 0 To go.ObjectCount - 1
Dim Mobjref As Rhino.DocObjects.ObjRef = go.[Object](i)
Dim Mobj As Rhino.DocObjects.RhinoObject = Mobjref.[Object]()
If Mobj Is Nothing Then
Return Result.Failure
End If
Dim Obrep As Rhino.Geometry.Brep = Mobjref.Brep
If Obrep Is Nothing Then
Continue For
End If
If listIndex <> 2 Then
Dim renewbreps() As Geometry.Brep = Obrep.Trim(recutterplane, RhinoDoc.ActiveDoc.PageAbsoluteTolerance)
' Dim Osrf As Surface = CType(rhinoObject.Geometry, Surface)
For Each nbrep As Geometry.Brep In renewbreps
RhinoDoc.ActiveDoc.Objects.AddBrep(nbrep, Mobj.Attributes)
Next
If Not opbl.CurrentValue And renewbreps.Count > 0 Then
Mreflist.Add(Mobjref)
End If
End If
If listIndex <> 1 Then
Dim newbreps() As Geometry.Brep = Obrep.Trim(Mcutterplane, RhinoDoc.ActiveDoc.PageAbsoluteTolerance)
' Dim Osrf As Surface = CType(rhinoObject.Geometry, Surface)
For Each nbrep As Geometry.Brep In newbreps
RhinoDoc.ActiveDoc.Objects.AddBrep(nbrep, Mobj.Attributes)
Next
If Not opbl.CurrentValue And newbreps.Count > 0 Then
Mreflist.Add(Mobjref)
End If
End If
Next
For Each oref As ObjRef In Mreflist
RhinoDoc.ActiveDoc.Objects.Delete(oref, False)
Next
RhinoDoc.ActiveDoc.Views.Redraw()
rc = Rhino.Commands.Result.Success
Return rc
End Function