Group Center Origin
52 4
vlrm.prjct 2 weeks ago
Ahio Guys, I don't know if it's a bug or if I'm doing something wrong. I am trying to create a "simple" PCB module. But when I group some of the elements, the central origin is lost. For example, the module below has only two circles, the centre is absolute to the canvas origin (x=0 and y=0), but the group centre is somewhere else. How can I set the origin of the grouped elements? It is a bit annoying when I add such modules to a PCB. ( The only solution I found is to use "footprint" instead of "pcb module", because footprints are always grouped by default with a correct origin. But this is not the right way because the footprint library gets messed up.  ) ![pcb_module-before-grouping](//image.easyeda.com/pullimage/6VO0w5LSqDZZOsqHJLNxIq8Cq9VRb7jPiNC153pv.jpeg)![pcb_module-after-grouping](//image.easyeda.com/pullimage/7K6XX9A90ium06DcbLjGzcGb7jQwkntdBs5Kayq1.jpeg)
Komentáře
andreasbernhofer 2 weeks ago
Looks like it is the center of all parts, but the initial bounding box of the prefix is included as part of the group when the center of the group is calculated. ![2022-01-10 17_58_41-Window.png](//image.easyeda.com/pullimage/ZZAnIWxOoLCBFIy9K9U71cAhlSRDvFQzt1R3iUlM.png) ![2022-01-10 18_00_42-Window.png](//image.easyeda.com/pullimage/wrSJiX7nHeNmqNQpBJCXNRo3Q5o8NMjd4JrLozQE.png)
Odpovědět
andreasbernhofer 2 weeks ago
Confirmed (I think)... Should be as simple as swapping two lines of code ;) ![2022-01-10 18_38_35-Window.png](//image.easyeda.com/pullimage/hC1XfMTcu0M6ffMDeMvexz9PAwUf057rt4kIO738.png)
Odpovědět
andreasbernhofer 2 weeks ago
@[vlrm.prjct](https://easyeda.com/tmeschke) btw. what you want is not only setting the group origin to its proper center (Bugfix), but maybe also setting a custom origin for the group, right? You can use this script to set the origin/center of the selected group to the current origin of the editor. That probably should be a separate Feature Request. ``` js // Set selected Group-Origin to Editors Origin group = api('getShape',{id: api('getSelectedIds')}); source = api('getSource', {type: "json"}); if(group?.head?.x !== undefined && source?.canvas?.originX !== undefined) { group.head.x = source.canvas.originX; group.head.y = source.canvas.originY; api('updateShape',{ shapeType: 'pcblib', jsonCache: group }); } ``` ![2022-01-10 19_15_01-Window.png](//image.easyeda.com/pullimage/SHDDgJCpMqi2e2WZFHYRvOd3ZTYLjY2NhFhNaOb2.png)
Odpovědět
vlrm.prjct 2 weeks ago
Ahio @andreasbernhofer, Thank you! Yep you are right. For me it is a bug. Why should the prefix label be part of a group? The point is, if you move, hide or rename the prefix, the origin doesn't change. Your second post saves my life ... \o/ ... and works pretty neat. Thank you again ! - - - Maybe someone will stumble across this post and try to run this snippet. But it won't work because of the ( in some cases ) unsupported questionmark syntax, which will end in a syntax error. The fixed version ( _if condition_ ) looks like this: ``` javascript if( (group && group.head && group.head.x !== undefined) && (source && source.canvas && source.canvas.originX !== undefined) ) { group.head.x = source.canvas.originX; group.head.y = source.canvas.originY; api('updateShape',{ shapeType: 'pcblib', jsonCache: group }); } ```
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.