Get world point from detail, need help

Hi guys, (@pascal) I am trying to get a point’s world coordinates by picking it on a detail.
I found a way to get a point, check if it is within a detail, get the details PageToWorldTransform, but then I got stuck on how to use that to convert the point. (It returns “None”)

What am I missing? Or is there an even easier way to do this in Python?

(Everything works fine down to the last annotation, it is the point.Transform(xform) that doesn’t return any results)

### Get World point from Detail.py
### WIP by Holo 2024

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

def runScript():
    ### Check if in a Layout
    view = rs.CurrentView()
    if not rs.IsLayout(view):
        print ("This is not a Layout")
        return
    
    ### Check if details in Layout
    details = []
    objs = rs.VisibleObjects()
    for obj in objs:
        if rs.IsDetail(view, obj):
            details.append(obj)
    if len(details)==0:
        print ("No details are visible")
        return
    
    ### Get point
    point = rs.GetPoint("")
    
    ### Check if point is within any details
    detail = None
    for test_detail in details:
        bbox = rs.BoundingBox(test_detail)
        
        if point.X > bbox[0][0] and point.X < bbox[1][0]:
            if point.Y > bbox[0][1] and point.Y < bbox[3][1]:
                detail = test_detail
                break
    
    if detail == None:
        print ("No details contained the point")
        return
    print ("The point is within detail:", detail)
    
    ### Get detail Page to World Xform
    detail = sc.doc.Objects.Find(detail)
    xform = detail.PageToWorldTransform
    worldPoint = point.Transform(xform)
    
    print worldPoint

runScript()
1 Like

Checking…

@Holo try


    detail = sc.doc.Objects.Find(detail)
    xform = detail.PageToWorldTransform
    point.Transform(xform)
    
    print (point)

-Pascal

2 Likes

Doh… so close :smile:
Of course it transforms the point instead of returning a transformed result. Thanks!

1 Like