Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset issue for 3D Model #20

Closed
uPesy opened this issue Mar 19, 2022 · 6 comments
Closed

Offset issue for 3D Model #20

uPesy opened this issue Mar 19, 2022 · 6 comments
Labels
bug Something isn't working help wanted Extra attention is needed Stale

Comments

@uPesy
Copy link
Owner

uPesy commented Mar 19, 2022

Hi,
I have not find the way to convert the offset of easyeda 3d model to KiCad 5.x

For exemple for ID C319148, here the JSON with only relevant data

"dataStr": {
                "head": {
                    "x": 4001.992,    // x origin footprint
                    "y": 2999.8101,  // y origin footprint
                },
                "canvas": "CA~1000~1000~#000000~yes~#FFFFFF~10~1000~1000~line~0.03937~mm~1~45~visible~0.5~4001.992~2999.8101~0~none",
                "shape": [
                    "SVGNODE~{\"gId\":\"g1_outline\",\"nodeName\":\"g\",\"nodeType\":1,\"layerid\":\"19\",\"attrs\":{\"c_width\":\"35.19678\",\"c_height\":\"31.1023\",\"c_rotation\":\"0,0,180\",\"z\":\"-3.5433\",\"c_origin\":\"4001.992,3004.2501\",\"uuid\":\"c50ce21ae3b941ce8eeb9bccc6cdef41\",\"c_etype\":\"outline3D\",\"id\":\"g1_outline\",\"title\":\"USB-3.1-SMD_16P-L8.9-W7.3-H3.3-P0.5\",\"layerid\":\"19\",\"transform\":\"scale(1) translate(0, 0)\"},\"childNodes\":[{\"gId\":\"g1_outline_line0\",\"nodeName\":\"polyline\",\"nodeType\":1,\"attrs\":{\"fill\":\"none\",\"id\":\"g1_outline_line0\",\"c_shapetype\":\"line\",\"points\":\""}}]}"
                ],
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Apr 19, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

@uPesy uPesy reopened this Jun 27, 2022
@uPesy
Copy link
Owner Author

uPesy commented Jun 27, 2022

I don't know how to properly set the offset of all 3D model for x, y , z offset. Here some relevant information :
For example for the 3D model of LCSC ID C319148
API result : https://easyeda.com/api/products/C319148/components?version=6.4.19.5
Here the data for the 3D model :

{
   "gId":"g1_outline",
   "nodeName":"g",
   "nodeType":1,
   "layerid":"19",
   "attrs":{
      "c_width":"35.19678",
      "c_height":"31.1023",
      "c_rotation":"0,0,180",
      "z":"-3.5433",
      "c_origin":"4001.992,3004.2501",
      "uuid":"c50ce21ae3b941ce8eeb9bccc6cdef41",
      "c_etype":"outline3D",
      "id":"g1_outline",
      "title":"USB-3.1-SMD_16P-L8.9-W7.3-H3.3-P0.5",
      "layerid":"19",
      "transform":"scale(1) translate(0, 0)"
   },
   "childNodes":[
      {
         "gId":"g1_outline_line0",
         "nodeName":"polyline",
         "nodeType":1,
         "attrs":{
            "fill":"none",
            "id":"g1_outline_line0",
            "c_shapetype":"line",
            "points":"4019.5904 3019.7618 4019.5904 3019.7224 4019.5904 3019.6831 4019.5904 3012.8327 4019.5904 3012.7933 4019.5904 3012.7539 4019.5904 3012.7146 4019.5904 3012.6752 4019.5904 3012.5571 4019.5904 3012.5177 4019.5904 3012.3996 4019.5904 3012.3602 4019.5904 3012.1634 4019.5904 3011.9272 4019.5904 3011.691 4019.5904 3011.4941 4019.5904 3011.3366 4019.5904 3011.2973 4019.5904 3011.1791 4019.5904 3011.1398 4019.5904 3011.1004 4019.5904 3011.061 4019.5904 3011.0217 4019.5904 3010.9823 4019.5904 3010.8642 4019.5904 3010.8248 4019.5904 3010.628 4019.5904 3010.5886 4019.5904 3010.313 4019.5904 3009.9587 4019.5904 3009.565 4019.5904 3009.1713 4019.5904 3008.8563 4019.5904 3008.8169 4019.5904 3008.5414 4019.5904 3008.502 4019.5904 3008.3051 4019.5904 3008.2658 4019.5904 3008.1477 4019.5904 3008.1083 4019.5904 3008.0689 4019.5904 3008.0295 4019.5904 3007.9902 4019.5904 3007.9508 4019.5904 3007.8721 4019.5904 3007.8327 4019.5904 3007.754 4019.5904 3005.9429 4019.5904 3005.9036 4019.5904 3005.8642 4019.5904 3005.7855 4019.5904 3005.7461 4019.5904 3005.7067 4019.5904 3005.6673 4019.5904 3005.628 4019.5904 3005.5886 4019.5904 3005.4705 4019.5904 3005.4311 4019.5904 3005.313 4019.5904 3005.2736 4019.5904 3005.0768 4019.5904 3004.8406 4019.5904 3004.6044 4019.5904 3004.4075 4019.5904 3004.25 4019.5904 3004.2107 4019.5904 3004.0925 4019.5904 3004.0138 4019.5904 3003.9744 4019.5904 3003.9351 4019.5904 2997.0847 4019.5904 2997.0059 4019.5904 2996.9272 4019.5904 2996.8485 4019.5904 2996.7697 4019.5904 2996.691 4019.5904 2996.6122 4019.5904 2996.5335 4019.5904 2996.4154 4019.5904 2996.1792 4019.5904 2995.9823 4019.5904 2995.7067 4019.5904 2995.5493 4019.5904 2995.3524 4019.5904 2995.2343 4019.5904 2995.1162 4019.5904 2995.0374 4019.5904 2994.88 4019.5904 2994.6831 4019.5904 2994.6044 4019.5904 2994.3682 4019.5904 2994.2894 4019.5904 2994.0138 4019.5904 2993.6201 4019.5904 2992.754 4019.5904 2992.6359 4019.5904 2992.2422 4019.5904 2991.8878 4019.5904 2991.5729 4019.5904 2991.3367 4019.5904 2991.1792 4019.5904 2991.1398 4019.551 2991.1004 4019.4723 2991.0611 4019.4329 2991.0611 4019.3148 2991.0611 4019.2361 2991.0611 4018.9605 2991.0611 4018.5668 2991.0611 4018.4881 2991.0611 4018.4093 2991.0611 4018.3306 2991.0611 4018.2518 2991.0611 4018.2125 2991.0611 4018.0944 2991.0611 4018.0156 2991.0611 4017.9762 2991.0611 4017.8188 2991.0611 4017.7794 2991.0611 4017.6613 2991.0611 4017.5432 2991.0611 4017.3857 2991.0611 4017.307 2991.0611 4017.2282 2991.0611 4017.1101 2991.0611 4016.9526 2991.0611 4016.8345 2991.0611 4016.7164 2991.0611 4016.5589 2991.0611 4016.3227 2991.0611 4016.2833 2991.0611 4016.2046 2991.0611 4015.6534 2991.0611 4015.4566 2991.0611 4015.4566 2988.6989 4013.8818 2988.6989 4013.8818 2991.0611 4012.4251 2991.0611 4012.4251 2988.6989 4010.8503 2988.6989 4010.8503 2991.0611 4010.4959 2991.0611 4010.4566 2991.0611 4009.9448 2991.0611 4009.7479 2991.0611 4009.6692 2991.0611 4009.2755 2991.0611 4009.2755 2988.6989 4008.4881 2988.6989 4008.4881 2991.0611 4008.0156 2991.0611 4007.9763 2991.0611 4007.7794 2991.0611 4007.74 2991.0611 4007.5038 2991.0611 4007.4645 2991.0611 4007.307 2991.0611 4007.307 2988.6989 4006.5196 2988.6989 4006.5196 2991.0611 4005.3385 2991.0611 4005.3385 2988.6989 4004.5511 2988.6989 4004.5511 2991.0611 4003.37 2991.0611 4003.37 2988.6989 4002.5826 2988.6989 4002.5826 2991.0611 4001.4015 2991.0611 4001.4015 2988.6989 4000.6141 2988.6989 4000.6141 2991.0611 3999.433 2991.0611 3999.433 2988.6989 3998.6456 2988.6989 3998.6456 2991.0611 3997.4645 2991.0611 3997.4645 2988.6989 3996.6771 2988.6989 3996.6771 2991.0611 3996.5196 2991.0611 3996.4802 2991.0611 3996.244 2991.0611 3996.2046 2991.0611 3996.0078 2991.0611 3995.9684 2991.0611 3995.496 2991.0611 3995.496 2988.6989 3994.7086 2988.6989 3994.7086 2991.0611 3994.3149 2991.0611 3994.2755 2991.0611 3993.5275 2991.0611 3993.4881 2991.0611 3993.1338 2991.0611 3993.1338 2988.6989 3991.559 2988.6989 3991.559 2991.0611 3990.0629 2991.0611 3990.0629 2988.6989 3988.4881 2988.6989 3988.4881 2991.0611 3988.3306 2991.0611 3987.7795 2991.0611 3987.7007 2991.0611 3987.6613 2991.0611 3987.2676 2991.0611 3987.1495 2991.0611 3987.1102 2991.0611 3986.9921 2991.0611 3986.7558 2991.0611 3986.6377 2991.0611 3986.5984 2991.0611 3986.4015 2991.0611 3986.3228 2991.0611 3986.2047 2991.0611 3986.1653 2991.0611 3985.9684 2991.0611 3985.8897 2991.0611 3985.8503 2991.0611 3985.6928 2991.0611 3985.6535 2991.0611 3985.5354 2991.0611 3985.4566 2991.0611 3985.3779 2991.0611 3984.9842 2991.0611 3984.7086 2991.0611 3984.6692 2991.0611 3984.4724 2991.0611 3984.433 2991.1004 3984.3936 2991.1792 3984.3936 2991.2186 3984.3936 2991.376 3984.3936 2991.6123 3984.3936 2991.8878 3984.3936 2992.2422 3984.3936 2992.6359 3984.3936 2993.6201 3984.3936 2994.0138 3984.3936 2994.3682 3984.3936 2994.6831 3984.3936 2994.9193 3984.3936 2995.0768 3984.3936 2995.1556 3984.3936 2995.2343 3984.3936 2995.3918 3984.3936 2995.5493 3984.3936 2995.7461 3984.3936 2995.9823 3984.3936 2996.1792 3984.3936 2996.4154 3984.3936 2996.6516 3984.3936 2996.8091 3984.3936 2996.9666 3984.3936 2997.0453 3984.3936 2997.0847 3984.3936 3003.9351 3984.3936 3003.9744 3984.3936 3004.0532 3984.3936 3004.0925 3984.3936 3004.2107 3984.3936 3004.25 3984.3936 3004.4075 3984.3936 3004.6044 3984.3936 3004.8406 3984.3936 3005.0768 3984.3936 3005.2736 3984.3936 3005.313 3984.3936 3005.4311 3984.3936 3005.4705 3984.3936 3005.5886 3984.3936 3005.628 3984.3936 3005.6673 3984.3936 3005.7067 3984.3936 3005.7461 3984.3936 3005.8248 3984.3936 3005.8642 3984.3936 3005.9036 3984.3936 3005.9429 3984.3936 3007.754 3984.3936 3007.8327 3984.3936 3007.8721 3984.3936 3007.9508 3984.3936 3007.9902 3984.3936 3008.0295 3984.3936 3008.0689 3984.3936 3008.1083 3984.3936 3008.1477 3984.3936 3008.2658 3984.3936 3008.3051 3984.3936 3008.502 3984.3936 3008.5414 3984.3936 3008.8169 3984.3936 3008.8563 3984.3936 3009.1713 3984.3936 3009.565 3984.3936 3009.9587 3984.3936 3010.313 3984.3936 3010.5886 3984.3936 3010.628 3984.3936 3010.8248 3984.3936 3010.8642 3984.3936 3010.9823 3984.3936 3011.0217 3984.3936 3011.061 3984.3936 3011.1004 3984.3936 3011.1398 3984.3936 3011.1791 3984.3936 3011.2973 3984.3936 3011.3366 3984.3936 3011.4941 3984.3936 3011.691 3984.3936 3011.9272 3984.3936 3012.1634 3984.3936 3012.3602 3984.3936 3012.3996 3984.3936 3012.5177 3984.3936 3012.5571 3984.3936 3012.6752 3984.3936 3012.7539 3984.3936 3012.7933 3984.3936 3012.8327 3984.3936 3019.6831 3984.3936 3019.7618 3984.433 3019.7618 3984.4724 3019.8012 3984.5117 3019.8012 3984.5511 3019.8012 3984.6692 3019.8012 3984.748 3019.8012 3984.9842 3019.8012 3985.1417 3019.8012 3985.4173 3019.8012 3985.496 3019.8012 3985.5747 3019.8012 3985.7322 3019.8012 3985.8897 3019.8012 3985.9684 3019.8012 3986.0078 3019.8012 3986.0865 3019.8012 3986.1653 3019.8012 3986.244 3019.8012 3986.3228 3019.8012 3986.4015 3019.8012 3986.5984 3019.8012 3986.7558 3019.8012 3986.8739 3019.8012 3986.9921 3019.8012 3987.1495 3019.8012 3987.2676 3019.8012 3987.4251 3019.8012 3987.5039 3019.8012 3987.6613 3019.8012 3987.7401 3019.8012 3987.7795 3019.8012 3988.3306 3019.8012 4001.992 3019.8012 4015.6534 3019.8012 4016.2046 3019.8012 4016.244 3019.8012 4016.3227 3019.8012 4016.5589 3019.8012 4016.7558 3019.8012 4016.992 3019.8012 4017.2282 3019.8012 4017.3857 3019.8012 4017.5825 3019.8012 4017.6613 3019.8012 4017.74 3019.8012 4017.8581 3019.8012 4018.0156 3019.8012 4018.0944 3019.8012 4018.1337 3019.8012 4018.2518 3019.8012 4018.2912 3019.8012 4018.4487 3019.8012 4018.5274 3019.8012 4018.6062 3019.8012 4018.8424 3019.8012 4018.9999 3019.8012 4019.2755 3019.8012 4019.3148 3019.8012 4019.4329 3019.8012 4019.5117 3019.8012 4019.551 3019.7618 4019.5904 3019.7618 4019.5904 3019.7618"
         }
      }
   ]
}

image

Width of the model is c_width * 10 in mil.
Height of the model is c_height * 10 in mil.
The z offset is z * 10 in mil.
c_origin are the x, y origin of the 3D model, but i don't know relative to what ?
The bbox origin in the footprint is "x" and "y" key

"head": {
    "docType": "4",
    "editorVersion": "6.5.1",
    "c_para": {
        "package": "USB-3.1-SMD_U262-161N-4BVC11",
        "pre": "U?",
        "Contributor": "\u7acb\u521bEDA\u5b98\u65b9\u5c01\u88c5\u5e93",
        "link": "https://item.szlcsc.com/300240.html",
        "3DModel": "USB-3.1-SMD_16P-L8.9-W7.3-H3.3-P0.5"
    },
    "hasIdFlag": true,
    "x": 4001.992,
    "y": 2999.81,
    "uuid": "74908a4f92b54467b858429c164269af",
    "utime": 1648689552,
    "importFlag": 0,
    "transformList": ""
}

At the end of JSON file sent by the API, there is a another BBox
"BBox": { "x": 3982.6, "y": 2987.6, "width": 38.7, "height": 33.3 }

In the code for now, it's the c_origin - footprint bbox, but it doesn't work:

ki_3d_model_info = Ki3dModel(
name=self.input.model_3d.name,
translation=Ki3dModelBase(
x=round((self.input.model_3d.translation.x - self.input.bbox.x), 2),
y=-round(
(self.input.model_3d.translation.y - self.input.bbox.y), 2
),
z=-round(self.input.model_3d.translation.z, 2),

Some kind of formula should be found between "c_origin", "x" and "y" footprint bbox, c_width and c_height , and maybe with the other "BBox" key too.

I try to look the code on EasyEDA, it's React production code, to find the formula. I found this, but i have not managed to get relevant offset :
In line 87700 of main.min.js :
image

Your help is really appreciated:)

Note that in the end, the dimensions should be converted in mm for Kicad

@uPesy uPesy added bug Something isn't working help wanted Extra attention is needed labels Jun 27, 2022
@Bouni
Copy link
Contributor

Bouni commented Jun 27, 2022

I'll take a look, probably this week, very busy at the moment ....

@uPesy uPesy removed the Stale label Jun 27, 2022
@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Aug 27, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 14 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed Stale
Projects
None yet
Development

No branches or pull requests

2 participants