master
Drew Owens Move the Base Scaffold Panel into this page as a sub-readme (panel/), 3D view at the top, drop section-ownership lines:… 7e86d5c
# Read-only: open "Base Scaffold 5 HOLES" invisibly, report screw/contact geometry, close unsaved.
import traceback
LINEAGE = 'urn:adsk.wipprod:dm.lineage:qYUGHjbdRKGe-Dwb6BSu6Q'
rep = {'activeBefore': app.activeDocument.name if app.activeDocument else None}
doc = None
try:
    doc = app.documents.open(app.data.findFileById(LINEAGE), False)
    des = adsk.fusion.Design.cast(doc.products.itemByProductType('DesignProductType'))
    root = des.rootComponent
    comps = {}
    xs, ys = set(), set()
    for occ in root.allOccurrences:
        c = occ.component
        e = comps.setdefault(c.name, {'n': 0, 'bodies': c.bRepBodies.count, 'meshBodies': c.meshBodies.count,
                                      'lightOff': 0, 'invisible': 0})
        e['n'] += 1
        if not occ.isLightBulbOn: e['lightOff'] += 1
        if not occ.isVisible: e['invisible'] += 1
        if c.name == 'MpinContact_Large v1':
            bb = occ.boundingBox
            xs.add(round((bb.minPoint.x + bb.maxPoint.x) * 5, 2)); ys.add(round((bb.minPoint.y + bb.maxPoint.y) * 5, 2))
            e['bboxMm'] = [round((bb.maxPoint.x - bb.minPoint.x) * 10, 3), round((bb.maxPoint.y - bb.minPoint.y) * 10, 3), round(bb.minPoint.z * 10, 3), round(bb.maxPoint.z * 10, 3)]
            if c.bRepBodies.count:
                b = c.bRepBodies.item(0)
                e['material'] = b.material.name if b.material else None
                e['appearance'] = b.appearance.name if b.appearance else None
        if c.name == 'Board' and c.bRepBodies.count:
            bb = c.bRepBodies.item(0).boundingBox
            e['bboxMm'] = [round((bb.maxPoint.x - bb.minPoint.x) * 10, 3), round((bb.maxPoint.y - bb.minPoint.y) * 10, 3), round(bb.minPoint.z * 10, 3), round(bb.maxPoint.z * 10, 3)]
    rep['components'] = comps
    rep['contactX'] = sorted(xs); rep['contactY'] = sorted(ys)
except Exception:
    rep['error'] = traceback.format_exc()
finally:
    if doc is not None:
        doc.close(False)
rep['activeAfter'] = app.activeDocument.name if app.activeDocument else None
result = rep