Author Topic: Altium Script to Add Document to BOM and Open Excel Template?  (Read 1630 times)

0 Members and 1 Guest are viewing this topic.

Offline Leviathan1Topic starter

  • Newbie
  • Posts: 3
  • Country: us
Hi all,
I've been scripting on Altium for about a month and made a script that can copy a file, edit its parameters, and create its own project. However, I am looking to next add this copied file to a premade output job file, assign an excel template to the bom, and generate said bom, all within the script.
However, I am unsure Altium's scripting feature allows for:
1. Adding a bom to the output job
2. Selecting an excel template for said bom
Although these are both possible to do by clicking (manually), Id like to automate this process, since clicking each schematic 50 times to add it to the output job and assign it the same template is killing my hands.

Thanks
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2607
  • Country: us
Re: Altium Script to Add Document to BOM and Open Excel Template?
« Reply #1 on: July 15, 2022, 05:46:12 pm »
I'm curious what underlying problem you're trying to solve, this sounds like the sort of thing that could be done much more easily a different way.

Are all of these files within one project and does the Excel template need to be different per file?  If not, then one option would be to never touch the outjob itself, but create individual projects that include the outjob (using a project template or whatever).  Make sure the outjob just targets all schematic files with the correct excel template preselected, and then you just need to generate the output.
 
The following users thanked this post: Leviathan1

Offline Leviathan1Topic starter

  • Newbie
  • Posts: 3
  • Country: us
Re: Altium Script to Add Document to BOM and Open Excel Template?
« Reply #2 on: July 15, 2022, 06:17:55 pm »
Thank you,
That sounds like a much better idea! My only concern with that is you mention preselecting the template, which I am unsure how to do. However, every schematic uses the same excel file as its template. Also, my schematics have their own project.
I also have a big pooled project, which I only have because I can create/use the output job for those 50+ files then click its template in one at a time rather than create a new output job in each individual project. Its saves the hassle of making one in every schematic's project (although both ways are tedious). This is why I like scripting.

I could not find a way to preset the excel template for a BOM. I have only been able to select a template once I have a schematic in the output job and I edit the settings for that schematic. I dont understand:
1. Is the concept of selecting an excel template from the script possible
2. If so, are there any functions or procedures recommended?

I've looked through the Altium's premade code and found one (with an epic 1500+ lines of code) that can make BOMs but not using output jobs, just txt output.
I think the underlying problem is I make cables on altium, and its quite repetitive and I'm trying to automate some things.
« Last Edit: July 15, 2022, 06:28:25 pm by Leviathan1 »
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2607
  • Country: us
Re: Altium Script to Add Document to BOM and Open Excel Template?
« Reply #3 on: July 15, 2022, 08:11:52 pm »
You can select "[Project]" as the data source for a BOM output, which will then assemble BOM data using all schematic sheets in the project.  If you have only one sheet in the project then that's equivalent to selecting the schematic sheet as the data source.  That selection is saved as part of the outjob, along with the selected template etc.  You may have to initially configure the outjob manually, but you can then save that outjob as part of a project template, and then any project created from the template will automatically include a copy of that outjob file.  I don't know if you can create a project from a template in a script, but if not then presumably you could use the script to add the outjob directly.  (Note that files can be included from outside of the project directory, so it should also be possible to have only one copy of that outjob referenced by all projects.  Occasionally Altium gets screwy and will use the wrong project as the data source if multiple projects that use the same outjob are open at the same time, I don't know if this would be a problem when scripting.)

I've also been using Altium for wire assemblies, but I tend to do one project for an entire set (product's worth) of wiring, and do BOMs, drawings, etc all at once.  I'd be curious about the application and workflow that got you to where you are.  I think we're going to be moving to Solidworks Electrical or something else better suited, though, mainly because Altium doesn't support multiple referential views to the same design objects, which makes doing multiple views (details, assembly steps, etc) a big pain, and it just plain blows as a drafting tool.  Integration with our existing Solidworks mechanical design workflow would just be a bonus at that point.
 

Offline Leviathan1Topic starter

  • Newbie
  • Posts: 3
  • Country: us
Re: Altium Script to Add Document to BOM and Open Excel Template?
« Reply #4 on: July 18, 2022, 09:21:22 pm »
This does work quite well, thank you.
As for Altium, I simply grab never photos of the cable from a rear and side view and use those in the library part for the connector. However Altium doesn't like me using images, and won't scale/flip them easily. Its generally difficult and clunky.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf