Get information out of an inactive Detail view - possible?

Hello!
I’m unsure if this is the right category, but anyway:
In the same manner as annotations can be associated to points inside a Detail (and even move with it) - is it possible in Python (or even GH Python) to pick a point of an inactive Detail and derive it’s coordinates?
Got some homegrown VisualArq height annotation objects here, which can show their Z coordinate automatically when moved. They have to be placed into the model space. Yet annotations of all kinds are a 2D-thing, and thus should be placed on a Layout.
So, when such an object is placed, some kind of point picking session on top of the Detail view should be invoked, and this point’s coords be read and displayed.

Obviously such a thing is possible (regular annotations). Also in scripting / Grasshopper?
Just doing a little research. A link to some helpful API page would be nice.
Thanks!

1 Like

@fsalla I am looking for the same thing. Thanks.

Hi @Eugen, @silvano,

Have a look at this and let me know if you have any questions.

import Rhino
import scriptcontext as sc

def test():
    gp = Rhino.Input.Custom.GetPoint()
    gp.SetCommandPrompt("Point location")
    gp.Get()
    if gp.CommandResult() != Rhino.Commands.Result.Success:
        return
    
    point = gp.Point()
    objref = gp.PointOnObject()
    if objref:
        detail_sn = objref.SelectionViewDetailSerialNumber()
        if detail_sn > 0:
            detail = sc.doc.Objects.Find(detail_sn)
            if isinstance(detail, Rhino.DocObjects.DetailViewObject):
                if detail.Viewport.IsParallelProjection:
                    print("Page location: {0}".format(point.ToString()))
                    point.Transform(detail.PageToWorldTransform)
                    print("World location: {0}".format(point.ToString()))
        else:
            print("World location: {0}".format(point.ToString()))
    else:
        print("Point location: {0}".format(point.ToString()))

if __name__ == '__main__':
    test()

– Dale

1 Like