-
Notifications
You must be signed in to change notification settings - Fork 335
/
Copy pathSampleDeselectObjects.py
52 lines (45 loc) · 1.89 KB
/
SampleDeselectObjects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
################################################################################
# SampleDeselectObjects.py
# Copyright (c) 2017 Robert McNeel & Associates.
# See License.md in the root of this repository for details.
################################################################################
import Rhino
# Demonstrates how to get seleced objects and allow the user to deselect them.
def SampleDeselectObjects():
go = Rhino.Input.Custom.GetObject()
go.SetCommandPrompt('Select objects')
go.EnablePreSelect(True, True)
go.EnablePostSelect(False)
go.SubObjectSelect = False
go.GetMultiple(1, 0)
if (go.CommandResult() != Rhino.Commands.Result.Success or 0 == go.ObjectCount):
Rhino.RhinoApp.WriteLine("No pre-selected objects.");
return None
go.DisablePreSelect()
go.EnablePostSelect(True)
go.AlreadySelectedObjectSelect = True
go.DeselectAllBeforePostSelect = False
go.EnableClearObjectsOnEntry(False)
go.EnableUnselectObjectsOnExit(False)
go.GetMultiple(1, 0)
if (go.CommandResult() != Rhino.Commands.Result.Success):
return None
# Normally, pre-selected objects will remain selected, when a
# command finishes, and post-selected objects will be unselected.
# This this way of picking, it is possible to have a combination
# of pre-selected and post-selected. So, to make sure everything
# "looks the same", lets select everything before finishing.
rc = []
for i in range(go.ObjectCount):
obj = go.Object(i).Object()
if obj:
obj.Select(True)
rc.append(obj.Id)
return rc
# Check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if __name__ == "__main__":
rc = SampleDeselectObjects()
if rc:
print rc