Hello,
I'm having a board with some components, leds and capacitors. all the leds has a prefix with running numbers 1-200 and related capacitors with prefix of c1-c200
I searched for the API code for rotating and moving parts:
api('rotate', {ids:["gge2","gge3"],degree:90});
And for moving:
api('moveObjsTo', {objs:["gge2","gge3"], x: api('coordConvert', {type:'real2canvas',x: '10mm'}), y: api('coordConvert', {type:'real2canvas',y: '10mm'})});
The issue is that I don't know how to get the mapping between the IDs into the prefix, I was trying to rotate and move it via prefix without any success.
Does anyone familiar with how I can get the mapping between all my parts prefix to IDs? or moving parts via prefix?
Hey,
you do know about "Format" -> "Distribute array"? You can use it to distribute the components in a regular pattern.
Or do you really need some arbitrary function based on the prefix? You can select e.g. all caps using the find function and the execute this:
api('getSelectedIds').split(',').forEach((id)=>{ shape = api('getShape',{id: id}); console.log(shape); prefix = Object.entries(shape.TEXT).filter(t=>t[1].type=='P')[0][1].text; // do your stuff with prefix and id })
Footprints are complex shapes. You can find the prefix via
Object.entries(shape.TEXT).filter(t=>t[1].type=='P')[0][1].text
which finds the TEXT of the footprint of typeP
.I'm sure there is a better function to get the prefix, but this is what came to my mind first ;)