API: How to rename objects?
122 1
rustybucket 4 months 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.
Komentáře
andreasbernhofer 2 weeks 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).
Odpovědět
Pro přidání komentáře se musíte Přihlásit nebo Registrovat
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
We use cookies to offer you a better experience. Detailed information on the use of cookies on this website is provided in our Privacy Policy. By using this site, you consent to the use of our cookies.