タイトルが異なりますが、こちらの続きです。
マウスカーソルの座標値を取得する2 - C#ATIA
不人気ですが、こちら諦めていないです。
自宅で細々と(半分寝ながら)作っていた時は上手くいかなかったの
ですが、何故か会社では上手くいきました。
#FusionAPI_python #Author-kantoku #Description-無限直線と面の交差テスト import adsk.core, adsk.fusion, traceback def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface #水平面 pnt_ori = adsk.core.Point3D.create(0, 0, 0) vec_h = adsk.core.Vector3D.create(0, 0, 1) surf_h = adsk.core.Plane.create(pnt_ori, vec_h) GetIntersectPosition(surf_h, [0,0,-10.0], [0,0,10.0]) GetIntersectPosition(surf_h, [5,0,-10.0], [5,0,10.0]) #垂直面 vec_v = adsk.core.Vector3D.create(1, 0, 0) surf_v = adsk.core.Plane.create(pnt_ori, vec_v) GetIntersectPosition(surf_v, [0,0,-10.0], [0,0,10.0]) GetIntersectPosition(surf_v, [5,0,-10.0], [5,0,10.0]) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) def GetIntersectPosition(plane, start, end): ui = None try: app = adsk.core.Application.get() ui = app.userInterface #直線 st_pnt = adsk.core.Point3D.create(start[0], start[1], start[2]) ed_pnt = adsk.core.Point3D.create(end[0], end[1], end[2]) line = adsk.core.Line3D.create(st_pnt, ed_pnt).asInfiniteLine() lst = line.intersectWithSurface(plane) if lst.count > 0 : pnt3d = lst[0] msg = 'x:{:.3f} y:{:.3f} z:{:.3f}'.format(pnt3d.x, pnt3d.y, pnt3d.z) ui.messageBox(msg) else: ui.messageBox('交差しません') except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
単位はCmなので役にたたないです。