Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I want to get(measure) face' radius .
who know how can do it.
Thankyou for your help.
Solved! Go to Solution.
Hi everyone,
I want to get(measure) face' radius .
who know how can do it.
Thankyou for your help.
Solved! Go to Solution.
Hi @ho-kou -San.
A script was created to select a cylindrical surface and display its radius.
The radius is obtained within the get_radius function.
# Fusion360API Python script
import traceback
import adsk.core as core
import adsk.fusion as fusion
def run(context):
ui: core.UserInterface = None
try:
app: core.Application = core.Application.get()
ui = app.userInterface
des: fusion.Design = app.activeProduct
msg: str = "Select"
selFilter: str = "CylindricalFaces"
sel: core.Selection = select_ent(msg, selFilter)
if not sel:
return
radius = get_radius(sel.entity)
if not radius: return
unitsMgr: core.UnitsManager = des.unitsManager
ui.messageBox(
f"{unitsMgr.formatInternalValue(radius)}",
"Radius",
)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def get_radius(
face: fusion.BRepFace,
) -> float:
geo = face.geometry
if geo.classType() != core.Cylinder.classType(): return None
cylinder: core.Cylinder = geo
return cylinder.radius
def select_ent(
msg: str,
filterStr: str
) -> core.Selection:
try:
app: core.Application = core.Application.get()
ui: core.UserInterface = app.userInterface
sel = ui.selectEntity(msg, filterStr)
return sel
except:
return None
hi @kandennti
Thank you very much for your code.
But i want to measure the brepface which type is "adsk.core.NurbsSurface".
Do you give me other idea.
Thank you for your help.
@ho-kou -San.
The following sample displays the radius at the clicked position of a face.
The curvature is the reciprocal of the radius.
# Fusion360API Python script
import traceback
import adsk.core as core
import adsk.fusion as fusion
def run(context):
ui: core.UserInterface = None
try:
app: core.Application = core.Application.get()
ui = app.userInterface
des: fusion.Design = app.activeProduct
# select face
msg: str = 'Select Face'
selFilter: str = 'Faces'
sel: core.Selection = select_ent(msg, selFilter)
if not sel: return
# get curvature
curvature = get_curvature(
sel.entity,
sel.point,
)
# get raduis
unitsMgr: core.UnitsManager = des.unitsManager
if curvature == 0:
raduis = "-"
else:
raduis = unitsMgr.formatInternalValue(
abs(1 / curvature)
)
ui.messageBox(raduis, "Raduis")
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def get_curvature(
face: fusion.BRepFace,
point: core.Point3D,
) -> float:
# https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-31dad9b2-ee1d-4216-8100-09ea44f9967a
eva: core.SurfaceEvaluator = face.evaluator
_, prm = eva.getParameterAtPoint(point)
_, _, curvature, _ = eva.getCurvature(prm)
return curvature
def select_ent(
msg: str,
filterStr: str
) -> core.Selection:
try:
app: core.Application = core.Application.get()
ui: core.UserInterface = app.userInterface
sel = ui.selectEntity(msg, filterStr)
return sel
except:
return None
All add-ins here are in Japanese, but the same process is used to display the radius of the mouse cursor position in real time.
https://github.com/kantoku-code/Fusion360_OnTheFly/tree/master