You need to use EasyEDA editor to create some projects before publishing
api select not working
833 4
BillyBuerger 6 years ago
I have a script that I use to auto-place a large number of components in the exact X/Y locations that I have defined.  The script clones an existing object, selects it, then moves it to the desired location.  It worked a couple months ago but it seems the editor has been updated since then.  When I try to run it now, it just gives a message that says "error".  I narrowed it down to the call to select.  I can even hard-code it like in the documentation example and it doesn't work... api('select', {ids:["gge5"]}); Did something change in the api or is there a bug that's causing this not to work?
Comments
BillyBuerger 6 years ago
Still doesn't work.  But not sure if the api changed or if I was just doing things a weird way but I only selected things to move them.  Looking at the api reference, I see I can move/rotate by passing the ids and don't have to select.  So I got my script running now.  That said, I still had to do something different that documented for the api to make it work.  I get the newIds from the clone but I can't pass that into move/rotate.  I had to convert newIds to a string before it would work.  Not sure what the type of object returned from clone is but it doesn't translate directly to a string which the move/rotate seems to expect. | | | --- | | var newIds = "" + api('clone', {ids:["gge5"]}); |
Reply
BillyBuerger 6 years ago
var newIds = "" + api('clone', {ids:["gge5"]});
Reply
Tutorials 6 years ago
Hi select api has a bug and doesn't work.  This issue will be fixed with next release. clone api returns an array of new id(s). var idArr = api('clone', {ids:['gge5']}); //idArr may be ['gge28'] var idArr = api('clone', {ids:['gge5', 'gge6']}); //idArr may be ['gge28', 'gge29']
Reply
BillyBuerger 6 years ago
Ah, got it.  I was putting quotes around the newIds instead of letting the array of ids pass in causing the issue.  This worked... var newIds = api('clone', {ids:["gge5"]}); api('moveObjs', {objs:newIds, addX:-13.0314960629921,addY:73.8582677165354}); api('rotate', {ids:newIds,degree:10}); Thanks for the help.
Reply
Login or Register to add a comment
goToTop
你现在访问的是EasyEDA海外版,建议访问速度更快的国内版 https://lceda.cn(需要重新注册)
如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在https://lceda.cn/editor 打开保存即可。
有问题联系QQ 3001956291 不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus-@1x -mockplus-

Cookie Notice

Our website uses essential cookies to help us ensure that it is working as expected, and uses optional analytics cookies to offer you a better browsing experience. To find out more, read our Cookie Notice