by adom
The Base Scaffold: your electronics workbench in the cloud, and the electro-mechanical foundation for all projects in Adom's Cloud Lab (Fort Worth, TX). System overview, customer interaction model, factory/workcell integration, and mechanical design (panels, alignment sheet, wiring).
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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
# Open "Base Scaffold 5 HOLES" (Main/Scaffolds) INVISIBLY so the active document of the
# other session is untouched, inventory it, export STEP, close without saving.
# The contacts carry a black-plastic placeholder appearance in the design; the export
# gives them Fusion's 'Gold - Polished' IN MEMORY ONLY (the design is closed unsaved).
import os, json, time, traceback
LINEAGE = 'urn:adsk.wipprod:dm.lineage:qYUGHjbdRKGe-Dwb6BSu6Q'
outdir = os.path.join(os.path.expanduser('~'), 'Downloads', 'adom-scaffold-panel')
os.makedirs(outdir, exist_ok=True)
rep = {'activeBefore': app.activeDocument.name if app.activeDocument else None}
t0 = time.time()
doc = None
try:
df = app.data.findFileById(LINEAGE)
rep['dataFile'] = {'name': df.name, 'version': df.versionNumber, 'latestVersion': df.latestVersionNumber,
'folder': df.parentFolder.name, 'project': df.parentProject.name}
doc = app.documents.open(df, False)
rep['openSec'] = round(time.time() - t0, 1)
des = adsk.fusion.Design.cast(doc.products.itemByProductType('DesignProductType'))
root = des.rootComponent
bb = root.boundingBox
rep['bboxMm'] = [round((bb.maxPoint.x - bb.minPoint.x) * 10, 3), round((bb.maxPoint.y - bb.minPoint.y) * 10, 3), round((bb.maxPoint.z - bb.minPoint.z) * 10, 3)]
rep['bboxMinMm'] = [round(bb.minPoint.x * 10, 3), round(bb.minPoint.y * 10, 3), round(bb.minPoint.z * 10, 3)]
rep['rootName'] = root.name
rep['rootBodies'] = [b.name for b in root.bRepBodies][:40]
counts = {}
for occ in root.allOccurrences:
n = occ.component.name
counts[n] = counts.get(n, 0) + 1
rep['occurrenceCounts'] = counts
rep['topOccurrences'] = [o.name for o in root.occurrences][:60]
rep['bodyCountAll'] = sum(1 for _ in root.bRepBodies) + sum(o.component.bRepBodies.count for o in root.allOccurrences)
gold_lib = app.materialLibraries.itemByName('Fusion Appearance Library').appearances.itemByName('Gold - Polished')
gold = des.appearances.itemByName('Gold - Polished') or des.appearances.addByCopy(gold_lib, 'Gold - Polished')
recolored = 0
for occ in root.allOccurrences:
if occ.component.name == 'MpinContact_Large v1':
for b in occ.component.bRepBodies:
if b.appearance is None or b.appearance.name != 'Gold - Polished':
b.appearance = gold
recolored += 1
rep['contactAppearance'] = {'set': 'Gold - Polished', 'bodiesRecolored': recolored, 'savedToDesign': False}
em = des.exportManager
step_path = os.path.join(outdir, 'base-scaffold-panel-v%d.step' % df.versionNumber)
opts = em.createSTEPExportOptions(step_path, root)
rep['stepOk'] = em.execute(opts)
rep['stepPath'] = step_path
rep['stepBytes'] = os.path.getsize(step_path) if os.path.exists(step_path) else None
except Exception:
rep['error'] = traceback.format_exc()
finally:
if doc is not None:
try:
doc.close(False)
rep['closed'] = True
except Exception as e:
rep['closeError'] = str(e)
rep['activeAfter'] = app.activeDocument.name if app.activeDocument else None
rep['totalSec'] = round(time.time() - t0, 1)
with open(os.path.join(outdir, 'export-report.json'), 'w') as f:
json.dump(rep, f, indent=1)
result = rep