Listing assemblies to spreadhees

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
SDKenney
Posts: 2
Joined: Sat Oct 02, 2021 8:24 am

Listing assemblies to spreadhees

Post by SDKenney »

import importXLSX
importXLSX.insert(u"C:/Users/Stephen/OneDrive/Documents/Documents/3D/Parts/TestSpreadsheet.xlsx","TankForList")

sheet = App.ActiveDocument.addObject("Spreadsheet::Sheet","MySpreadsheet")
cell = 0
for x in App.ActiveDocument.Objects:
cell = cell + 1
sheet.set("A" + str(cell), x.Label)
App.ActiveDocument.recompute()

I have written a macro to generate assemblies using 'Merge Project' & 'Placement' so the parts do not have 'A2plus' related spreadsheets.
In the above (Copied/pasted from other sources) line 2 can import a spreadsheet complete with data & formulae etc. for sorting
The remainder starts a blank spreadsheet and (with the aid of filters) lists the parts.
So far I have failed to list the parts to the imported spreadsheet (For sorting/processing)
Any ideas how to do this (or export parts list to an external spreadsheet)

OS: Windows 10 Version 2004
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United Kingdom (en_GB)
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: Listing assemblies to spreadhees

Post by mario52 »

Hi

just for see examples macros work with spreadSheet :

Macro_FCTreeView Image

Macro_FCSpreadSheet_Extract Image

Macro_FCInfo Image

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
SDKenney
Posts: 2
Joined: Sat Oct 02, 2021 8:24 am

Re: Listing assemblies to spreadhees

Post by SDKenney »

Thanks. There was plenty to work from but could not find the one-liner that I thought might work. Finished up exporting the generated spreadsheet using the button on the spreadsheet workbench. This may be a manual fix but it gets you there. I can now set about merging spreadsheets for sorting/processing.
SDKenney
Post Reply