I’m looking for a way to pick/select an object within a detail while working in a Layout view.
Specifically I’d like to pick a single object visible in the detail to use for annotating usertext with a leader.
Can anyone point me in the right direction how to do this with python/rhinocommon?
not sure if this is helpful, but if multiple details are on the layout page, you’ll need to enable one of the details to pick something from it. So what about first picking detail, enabling it, then pick the object and once you’ve added your leader just disabling the detail to get back to the page view ?
import Rhino
import rhinoscriptsyntax as rs
def DoSomething():
# get the detail
detail_id = rs.GetObject("Select Detail", 32768, True, False)
if not detail_id: return
# enable detail
detail_obj = rs.coercerhinoobject(detail_id, True, True)
detail_obj.IsActive = True
# pick object in detail
id = rs.GetObject("Pick object", 0, False, False)
if not id: return
# TODO / read user data or do something with picked object
# disable detail
detail_obj.IsActive = False
DoSomething()
Or do you want to pick object inside the detail without having it activated ?
just to answer my own question, i guess this would do it to get the object without activated detail:
import Rhino
import rhinoscriptsyntax as rs
def DoSomething():
gp = Rhino.Input.Custom.GetPoint()
gp.SetCommandPrompt("Pick point on object")
get_rc = gp.Get()
if gp.CommandResult() != Rhino.Commands.Result.Success:
return
objref = gp.PointOnObject()
if objref:
rs.SelectObject(objref.ObjectId)
DoSomething()
Thanks for the examples, the last got me on another track:
There is an attribute InactiveDetailPickEnabled for Cutom.GetObject.
Still there is an issue that when picking this way, the objects in the detail will not highlight when the selection menu comes up. @dale is that something you can help with.
Issue is that a Cutom.GetObject with InactiveDetailPickEnabled set to true, will allow object in a detail to be picked. However when the menu for multiple possible objects comes up, there is no high-lite in the detail:
Yet for objects in s detail there is no high-lite:
-Willem
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
def GetObjectInDetail(message=None):
sc.doc.Objects.UnselectAll()
sc.doc.Views.Redraw()
go = Rhino.Input.Custom.GetObject()
go.SetCommandPrompt(message)
go.InactiveDetailPickEnabled = True
go.EnableHighlight(True)
go.AcceptNothing(True)
if go.Get()!=Rhino.Input.GetResult.Object: return None
objref = go.Object(0)
obj = objref.Object()
go.Dispose()
obj.Select(True)
return obj.Id
GetObjectInDetail('pick object')
But I just did and there is still no highlighting of objects when the multi-selection box pops up…
Actually it seems there is more to it. The Video below is a regular pick on in layout page (after the move command) I do get a highlite in an active detail, but not in the layout picking the 2 details…odd
Is there anything I can test or do to track this down?
That code will help me a lot. I would like to use the x,y,z coordinates of the point where I pick the object, (like using the GetObjectEx) and the layer name of the object picked