-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SampleGetSpecificObjectGrip.py
- Loading branch information
1 parent
9338980
commit 2a74f75
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
################################################################################ | ||
# SampleGetSpecificObjectGrip.py | ||
# Copyright (c) 2018, Robert McNeel & Associates. | ||
# See License.md in the root of this repository for details. | ||
################################################################################ | ||
import System | ||
import Rhino | ||
import rhinoscriptsyntax as rs | ||
|
||
# If you want to limit grip object selection to a specific object, | ||
# then you can use a custom GetObject class that behaves | ||
# similar to this one. | ||
class GetSpecificObjectGrip(Rhino.Input.Custom.GetObject): | ||
|
||
def __init__(self, owner_id): | ||
self.m_owner_id = owner_id | ||
self.GeometryFilter = Rhino.DocObjects.ObjectType.Grip | ||
self.SubObjectSelect = False | ||
|
||
def CustomGeometryFilter(self, rhino_object, geometry, component_index): | ||
if isinstance(rhino_object, Rhino.DocObjects.GripObject): | ||
if self.m_owner_id == rhino_object.OwnerId: | ||
return True | ||
return False | ||
|
||
# Tests the sample class (above) | ||
def SampleGetSpecificObjectGrip(): | ||
# Replace the id (below) with your own... | ||
object_id = System.Guid('782b7f20-8353-4066-be42-bd3f08791340') | ||
go = GetSpecificObjectGrip(object_id) | ||
go.SetCommandPrompt('Select grips') | ||
go.GetMultiple(1, 0) | ||
# TODO... | ||
|
||
# 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__": | ||
SampleGetSpecificObjectGrip() |