Hi @pavlo.sulimenko .
I'm sure there are other ways, but I made a sample using the Component.findBRepUsingRay method.
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7CE5A6D9-BB79-4A6C-9634-587BFF5FE077

# Fusion360API Python script
import traceback
import adsk.fusion
import adsk.core
def run(context):
ui = adsk.core.UserInterface.cast(None)
try:
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
msg: str = 'Select Body'
selFiltter: str = 'Bodies'
sel: adsk.core.Selection = selectEnt(msg, selFiltter)
if not sel:
return
targetBody: adsk.fusion.BRepBody = sel.entity
# get Points from Top
pnts = getPointsFromTop(targetBody, 10)
# dump points - TextCommand Window
app.log(u'TextCommandWindow.Clear')
p: adsk.core.Point3D
for p in pnts:
app.log(f'{p.asArray()}')
# dump points - Sketch Points
comp: adsk.fusion.Component = targetBody.parentComponent
skt: adsk.fusion.Sketch = comp.sketches.add(
comp.xYConstructionPlane
)
skt.name = 'from the top'
skt.isComputeDeferred = True
sktPnts: adsk.fusion.SketchPoints = skt.sketchPoints
for p in pnts:
sktPnts.add(p)
skt.isComputeDeferred = False
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def getPointsFromTop(
targetBody: adsk.fusion.BRepBody,
stepCount: int = 10) -> list:
comp: adsk.fusion.Component = targetBody.parentComponent
bBox: adsk.core.BoundingBox3D = targetBody.boundingBox
minPnt: adsk.core.Point3D = bBox.minPoint
maxPnt: adsk.core.Point3D = bBox.maxPoint
stepX = (bBox.maxPoint.x - bBox.minPoint.x) / stepCount
stepY = (bBox.maxPoint.y - bBox.minPoint.y) / stepCount
tempPnts = []
for idxX in range(stepCount + 1):
for idxY in range(stepCount + 1):
tempPnts.append(
adsk.core.Point3D.create(
minPnt.x + stepX * idxX,
minPnt.y + stepY * idxY,
maxPnt.z + 1
)
)
rayDirection: adsk.core.Vector3D = adsk.core.Vector3D.create(
0, 0, -1
)
pnts = []
hitPnts: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
for pnt in tempPnts:
hitPnts.clear()
bodies: adsk.core.ObjectCollection = comp.findBRepUsingRay(
pnt,
rayDirection,
adsk.fusion.BRepEntityTypes.BRepBodyEntityType,
-1.0,
True,
hitPnts
)
if bodies.count < 1:
continue
bodyLst = [b for b in bodies]
hitPntLst = [p for p in hitPnts]
for body, pnt in zip(bodyLst, hitPntLst):
if body == targetBody:
pnts.append(pnt)
continue
return pnts
def selectEnt(
msg: str,
filterStr: str) -> adsk.core.Selection:
try:
app = adsk.core.Application.get()
ui = app.userInterface
sel = ui.selectEntity(msg, filterStr)
return sel
except:
return None
After executing the script, select the body.
However, if the body is not the root component, it will not be processed correctly.