| FORUM

FEDEVEL
Platform forum

Is there a script for Altium for component placement?

miner_tom , 07-07-2021, 07:08 PM
Robert,

I have found a script that is supposedly used for component placement at https://github.com/Altium-Designer-a...ipts-libraries. It does not really work well. I am looking for something simple, where one chooses a component reference designator and then places that component on the PCB, just using software (not pointing and clicking). It seems that there must be something like that available.

Regards
Tom
qdrives , 07-11-2021, 09:46 AM
Not the answer to your question, but why would you want a script to place components?
How should the script determine where to place that components?

Did you know that using cross probing you can select multiple components in the schematic and place the footprints in order?

Anyhow, if the script does not do exactly as you want, you have the source so you can change the script yourself.

Scripts seem a bit dead in Altium. You do not read much about it. I think that the bugs I reported on them still have not been fixed.
miner_tom , 07-11-2021, 02:20 PM

qdrives

Thank you for responding and contributing to this discussion.

I have a one word answer to the question that you asked: "but why would you want a script to place components?" The answer is ALGORITHMS. Your second question: "How should the script determine where to place that components?". Well, same answer.

We both know that it is very difficult to place components such as decoupling capacitors underneath dense packages such as a BGA. There are such algorithms that deal with "rectangle packing" and "bin packing", and I have worked with both in the past although not in the sense that has anything to do with PCB layout. So, let us make an assumption that it would be possible to specify a two dimensional area, of a specific grid density, that would hold the specified capacitors of a specific dimension. With that assumption satisfied, one could also add the constraint that would minimize the length of the tracks from the via (vias would be pre placed) to the component. That is the idea, anyway.

Now, I have not spent a lot of brain power thinking of the specific way to do this. But, in order for me to start, I would need to know how to pick a specific component (already in the netlist) and place it somewhere else at a specific coordinate on the PCB.

Yes, you are correct about the utility of "cross probing" (although it does not work as well in Altium 21 as it did in 18 because the line showing the connection between the component and its respective net is not as visible as it used to be no matter the settings. I have verified this with Robert.).

You are also correct in that "Scripts seem a bit dead in Altium. You do not read much about it.". I have a feeling that this would change or could change when Altium is finally ported to C# from whatever language it is now written in (Delphi, I think). In fact, from what I read, the change over of 2M lines of code is so herculean a task that they do it in stages, and that is part of the reason why capabilities change somewhat from version to version.

So, yes, I have not seen a "simple" script that says works like "take C247 and place it at x=something and y=something". An algorithm like such as the one that I propose could be worked out completely outside of Altium, in software, but eventually, one needs to be able to script in Altium.

Regards
Tom



WhoKnewKnows , 07-11-2021, 02:25 PM
Perhaps a future YouTube Video from @robertferanec could explain how one uses scripting in Altium and provide a few examples of why one would want to use scripting. ¯\_(ツ)_/¯
robertferanec , 07-12-2021, 01:03 AM
I have never created any scripts in Altium - I wanted to try it, just I could never justify to myself why I would do it (simply to say I have never really needed one).

PS: If you would like to just test an algoritm and if you can't find a simple script to manipulate with components in Altium PCB, a different simple way to manipulate with components may be to use PCB list: https://youtu.be/wgdCJ1rbNnA

PSS: The crossprobe: there are some settings which you may need to have set correctly and then it works oki again: https://designhelp.fedevel.com/forum...5970#post15970
Comments:
miner_tom, 07-15-2021, 02:20 PM
Robert, thank you for the suggestion. This method is a good place to start for what I expect to be able to do. I will share it if it ever comes to completion. Lots of work still ahead.
qdrives , 07-15-2021, 07:50 PM
I have created scripts in the past for Altium. The documentation is not very extensive, you need examples and a lot of trying/testing.
And yes @miner_tom you are right that Altium was written in Delphi. My fear is more that when times comes to convert the scripting part to C#, it will be removed as not interesting.
By the way, PCB library expert uses scripts to create the component footprint too.

If it comes to placing a component to a specific position, I do not think that is a difficult thing to do:
1) "Find" the component from the collection.
2) Change the position X and Y
But I do not know when you call a script "simple". What I mention here can easily be 200 lines of code.


As to "why one would want to use scripting" (as asked by @WhoKnewKnows ) - in those rare situation that Altium does not have something for it and it either takes a long time to do it manually, or it needs to be repeated often.


That said, coming back to the original "why": I have seen to many videos from Robert where capacitor placement is critical (especially the simulation ones), that I do think that creating the algorithm is much more time then doing it manually. Do note, I am not talking about the script, but the reasoning why/where a component must be placed. If it were that 'simple' auto-placing components would be available just as auto-routing. The human mind can try thousands of variations in their head before picking one - sometimes good and sometimes bad.
But don't mind me, when you have created it, I might be the first to say "Yes, finally!"
Comments:
miner_tom, 07-15-2021, 08:34 PM
qdrives, thank you for your comments in this discussion. Of course, if I ever get this going, it is is viable, I will post it to this forum for you to test. Tom
Use our interactive Discord forum to reply or ask new questions.
Discord invite
Discord forum link (after invitation)

Didn't find what you were looking for?