You need to use EasyEDA editor to create some projects before publishing
Change of all footprint label sizes using API
819 2
mwielgus 6 years ago

Hello.
The following script does not work as desired:

var json = api('getSource', {type: 'json'});
for (var i in json.FOOTPRINT) {
  if (json.FOOTPRINT.hasOwnProperty(i)) {
    for (var ii in json.FOOTPRINT[i].TEXT) {
      if (json.FOOTPRINT[i].TEXT.hasOwnProperty(ii)) {
        json.FOOTPRINT[i].TEXT[ii].strokeWidth = 0.6;
        json.FOOTPRINT[i].TEXT[ii].fontSize = 3.2;
      }
    }
  }
}
api('applySource', {source: json, createNew: true});

. The code is supposed to change the sizes of all of the footprint labels to `6 [mil]` width and `32 [mil]` height. However, it appears that only the widths are changed; the heights aren't changed in the layout view, despite that the value shown in the properties display window is changed to `32 [mil]`. In other words, the heights changed only in the properties display window - but they didn't change in the displayed layout.

Comments
mwielgus 6 years ago

Bump. It's been 6 days since I started this thread. I am yet to receive a reply. Please help, I need this functionality.

Reply
eric 6 years ago

You need to clear the cached pathStr by adding json.FOOTPRINT[i].TEXT[ii].pathStr = '';

var json = api('getSource', {type: 'json'});
for (var i in json.FOOTPRINT) {
  if (json.FOOTPRINT.hasOwnProperty(i)) {
    for (var ii in json.FOOTPRINT[i].TEXT) {
      if (json.FOOTPRINT[i].TEXT.hasOwnProperty(ii)) {
        json.FOOTPRINT[i].TEXT[ii].strokeWidth = 0.6;
        json.FOOTPRINT[i].TEXT[ii].fontSize = 3.2;
        json.FOOTPRINT[i].TEXT[ii].pathStr = '';   //add this line to reset pathStr
      }
    }
  }
}
api('applySource', {source: json, createNew: true});

It works well as my testing.

Reply

Login or Register to add a comment
goToTop
你现在访问的是EasyEDA海外版,建议访问速度更快的国内版 https://lceda.cn(需要重新注册)
如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在https://lceda.cn/editor 打开保存即可。
联系我们:https://docs.lceda.cn/cn/FAQ/Contact-Us/index.html不再提醒
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