Skip to content

Instantly share code, notes, and snippets.

@sbaer
Created August 28, 2017 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbaer/5d37c41dc40040f6367de8ca341bfaf1 to your computer and use it in GitHub Desktop.
Save sbaer/5d37c41dc40040f6367de8ca341bfaf1 to your computer and use it in GitHub Desktop.
import rhinoscriptsyntax as rs
import Rhino
def ModifyInstancePiece():
rs.UnselectAllObjects()
go = Rhino.Input.Custom.GetObject()
go.SubObjectSelect = True
go.Get()
if go.CommandResult() != Rhino.Commands.Result.Success:
return
objref = go.Object(0)
part = objref.InstanceDefinitionPart()
if part:
val = rs.GetUserText(part, "counter")
c = 1
if val:
print val
c = int(val) + 1
else:
print "no user text yet"
rs.SetUserText(part, "counter", c)
rs.UnselectAllObjects()
#hold down ctrl+shift to sub object select
ModifyInstancePiece()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment