Fusion360で球体を作成する場合、プリミティブで作成してもスケッチを使い回転で
作成しても、サーフェスは1枚になるようです。(CATIAは2枚)
念の為、2枚に分割されても正しく球体と判断出来るようにしたつもりです。
又、立方体時とは異なり、拡張メソッドにしてみました。
・・・pythonの場合の名称が "拡張メソッド” で正しいのか不安。
#Fusion360API Python script #Author-kantoku #Description-球体の判断 import adsk.core, adsk.fusion, traceback import math def run(context): ui = None try: app :adsk.core.Application = adsk.core.Application.get() ui :adsk.core.UserInterface = app.userInterface des :adsk.fusion.Design = app.activeProduct root :adsk.fusion.Component = des.rootComponent # 拡張 adsk.fusion.BRepBody.isSphere = isSphere res = [] for body in root.bRepBodies: res.append('[{}]-{}'.format(body.name, body.isSphere())) msg = 'ルートコンポーネント内のボディが球体か?\n' + '\n'.join(res) ui.messageBox(msg) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) def isSphere( self :adsk.fusion.BRepBody) -> bool: # すべて球面か? sr = adsk.core.SurfaceTypes.SphereSurfaceType if len([fc for fc in self.faces if fc.geometry.surfaceType != sr]) > 0: return False # 半径は一致しているか? if len(set([round(fc.geometry.radius, 4) for fc in self.faces])) > 1: return False # 面積は正しいか? r = self.faces.item(0).geometry.radius if abs(4 * math.pi * r * r - self.area) > 0.001: return False return True