import sys, io sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace', write_through=True) import win32com.client as wc def prop(o,n): v = getattr(o,n) return v() if type(v).__name__ in ('method','function','builtin_function_or_method') else v D = lambda x: x if hasattr(x,'_oleobj_') else wc.Dispatch(x) app = wc.GetActiveObject('SldWorks.Application') part = app.ActiveDoc print('doc', prop(part,'GetTitle')) fs = prop(D((part.GetBodies2(0,True) or [])[0]), 'GetFaces') for f in fs: fc = D(f); s = prop(fc,'GetSurface') if not prop(s,'IsCylinder'): continue cp = list(prop(s,'CylinderParams')) r = cp[6]*1000 if abs(r-2.1) > 0.01: continue fb = [round(v*1000,2) for v in prop(fc,'GetBox')] print(' R%.2f axis=(%.0f,%.0f,%.0f) box x %.2f~%.2f y %.2f~%.2f z %.2f~%.2f' % ( r, cp[3],cp[4],cp[5], fb[0],fb[3],fb[1],fb[4],fb[2],fb[5]))