asdasdasd
Script to add wires for all pins
I created this script to add wires for all pins in the schematic. I hope you like it: function getRandomId() { return "gge" + Math.round(Math.random() * 10000000); } const ids = api('getSelectedIds'); const result = api('getSource', {type:'json'}); function addWire(x1, y1, x2, y2) { gId = getRandomId(); result.wire[gId] = { gId, pointArr: [{x:x1,y:y1}, {x:x2,y:y2}], locked: '0', strokeColor: '#008800', strokeWidth: '1', strokeStyle: '0', fillColor: 'none', }; } if (!(ids in result.schlib)) { alert("Please select object"); return; } const o = result.schlib[ids]; const allX = Object .keys(o.pin) .map(p => o.pin[p].configure.x); const minX = Math.min(...allX); const maxX = Math.max(...allX); Object.keys(o.pin).forEach(p => { const x = o.pin[p].configure.x; const y = o.pin[p].configure.y; let xx = x; if (x == minX) xx -= 50; else if (x == maxX) xx += 50; else return; addWire(x, y, xx, y); }); api('applySource', {source: result, createNew: false}); https://gist.github.com/kargeor/8a7444b68ed164409fb5935d375f5a77 #Skill#
kargeor 2021-03-14 11:44:53 comment 2 0 Circuit Design