You need to use EasyEDA editor to create some projects before publishing
API: How to rename objects?
510 1
rustybucket 3 years ago
How do I use the api's "updateShape" method to rename objects? Let's say I have a netPort named "INPUT1" and I want to change it to "INPUT2". I've tried: <span class="colour" style="color:rgb(187, 187, 187)">    </span><span class="colour" style="color:rgb(38, 139, 210)">api</span><span class="colour" style="color:rgb(187, 187, 187)">(</span><span class="colour" style="color:rgb(42, 161, 152)">"updateShape"</span><span class="colour" style="color:rgb(187, 187, 187)">, {</span> <span class="colour" style="color:rgb(187, 187, 187)">        </span><span class="colour" style="color:rgb(38, 139, 210)">shapeType</span><span class="colour" style="color:rgb(187, 187, 187)">: </span><span class="colour" style="color:rgb(42, 161, 152)">"netport"</span><span class="colour" style="color:rgb(187, 187, 187)">,</span> <span class="colour" style="color:rgb(187, 187, 187)">        </span><span class="colour" style="color:rgb(38, 139, 210)">name</span><span class="colour" style="color:rgb(187, 187, 187)">: </span><span class="colour" style="color:rgb(42, 161, 152)">"INPUT2"</span><span class="colour" style="color:rgb(187, 187, 187)">,</span> <span class="colour" style="color:rgb(187, 187, 187)">        </span><span class="colour" style="color:rgb(38, 139, 210)">gId</span><span class="colour" style="color:rgb(187, 187, 187)">: "</span>gge2619<span class="colour" style="color:rgb(187, 187, 187)">"</span> <span class="colour" style="color:rgb(187, 187, 187)">    });</span><br> <br> But this doesn't work. Please help.
Comments
andreasbernhofer 2 years ago
@[rustybucket](https://easyeda.com/rustybucket) Not sure if this is the proper way, but it works... ``` js netflag = api('getShape',{id: 'gge2619'}); netflag.mark.netFlagString = 'INPUT2'; netflag.gId = netflag.configure.gId; // gId is required as main object property for updateShape api('updateShape',{shapeType: 'netflag', jsonCache: netflag}); ``` I've used it in a [small script that realigns/centers the text on netPorts](https://github.com/xsrf/easyeda-extension-example/blob/8eab21749326cfe99bc7f2e9b776a9c8f0870d4e/stuff.js#L602).
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