{"action":"created","issue":{"url":"https://api.github.com/repos/WoLpH/numpy-stl/issues/52","repository_url":"https://api.github.com/repos/WoLpH/numpy-stl","labels_url":"https://api.github.com/repos/WoLpH/numpy-stl/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/WoLpH/numpy-stl/issues/52/comments","events_url":"https://api.github.com/repos/WoLpH/numpy-stl/issues/52/events","html_url":"https://github.com/WoLpH/numpy-stl/issues/52","id":223209680,"number":52,"title":"mesh.from_file throws Assertion Error if matplotlib figure is open when speedups=True","user":{"login":"alexblaessle","id":16922191,"avatar_url":"https://avatars2.githubusercontent.com/u/16922191?v=3","gravatar_id":"","url":"https://api.github.com/users/alexblaessle","html_url":"https://github.com/alexblaessle","followers_url":"https://api.github.com/users/alexblaessle/followers","following_url":"https://api.github.com/users/alexblaessle/following{/other_user}","gists_url":"https://api.github.com/users/alexblaessle/gists{/gist_id}","starred_url":"https://api.github.com/users/alexblaessle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexblaessle/subscriptions","organizations_url":"https://api.github.com/users/alexblaessle/orgs","repos_url":"https://api.github.com/users/alexblaessle/repos","events_url":"https://api.github.com/users/alexblaessle/events{/privacy}","received_events_url":"https://api.github.com/users/alexblaessle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-04-20T21:44:11Z","updated_at":"2017-05-03T20:56:29Z","closed_at":null,"body":"I run into troubles loading .stl files with ``stl.Mesh.from_file`` when there is some instance of matplotlib or Qt running in the same process. That is\r\n\r\n```` \r\nimport stl\r\nimport matplotlib.pyplot as plt\r\n\r\nmesh=stl.Mesh.from_file(pathToStlFile)\r\n````\r\n\r\nworks great. However, if before initiate a matplotlib figure, that is\r\n\r\n````\r\nplt.figure()\r\nmesh=stl.Mesh.from_file(pathToStlFile)\r\n````\r\n\r\nI get the following ``Assertion Error``:\r\n\r\n````\r\n File \"/usr/local/lib/python2.7/dist-packages/stl/stl.py\", line 316, in from_file\r\n    fh, mode=mode, speedups=speedups)\r\n  File \"/usr/local/lib/python2.7/dist-packages/stl/stl.py\", line 85, in load\r\n    name, data = cls._load_binary(fh, header, check_size=True)\r\n  File \"/usr/local/lib/python2.7/dist-packages/stl/stl.py\", line 102, in _load_binary\r\n    count, MAX_COUNT)\r\nAssertionError: File too large, got 909389366 triangles which exceeds the maximum of 100000000\r\n````\r\n\r\nLooking through the code in ``BaseStl`` and reading through this issue https://github.com/WoLpH/numpy-stl/issues/37, I realized that this is due to the fallback if ``_load_ascii`` throws a runtime error such as \r\n\r\n````\r\n File \"/usr/local/lib/python2.7/dist-packages/stl/stl.py\", line 212, in _load_ascii\r\n    return _speedups.ascii_read(fh, header)\r\n  File \"stl/_speedups.pyx\", line 132, in stl._speedups.ascii_read (stl/_speedups.c:2613)\r\nRuntimeError: (0, \"Can't read vertex (4:vertex 176.46 176.46 0)\")\r\n````\r\n\r\nSo it seems that somehow the speedup is not working properly (some Cython clash with Qt/matplotlib?). Turns out that \r\n\r\n````\r\nplt.figure()\r\nmesh=stl.Mesh.from_file(pathToStlFile,speedup=False)\r\n````\r\n\r\nworks great. This took me a while to figure out and I thought it might be interesting."},"comment":{"url":"https://api.github.com/repos/WoLpH/numpy-stl/issues/comments/299032929","html_url":"https://github.com/WoLpH/numpy-stl/issues/52#issuecomment-299032929","issue_url":"https://api.github.com/repos/WoLpH/numpy-stl/issues/52","id":299032929,"user":{"login":"hroncok","id":2401856,"avatar_url":"https://avatars1.githubusercontent.com/u/2401856?v=3","gravatar_id":"","url":"https://api.github.com/users/hroncok","html_url":"https://github.com/hroncok","followers_url":"https://api.github.com/users/hroncok/followers","following_url":"https://api.github.com/users/hroncok/following{/other_user}","gists_url":"https://api.github.com/users/hroncok/gists{/gist_id}","starred_url":"https://api.github.com/users/hroncok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hroncok/subscriptions","organizations_url":"https://api.github.com/users/hroncok/orgs","repos_url":"https://api.github.com/users/hroncok/repos","events_url":"https://api.github.com/users/hroncok/events{/privacy}","received_events_url":"https://api.github.com/users/hroncok/received_events","type":"User","site_admin":false},"created_at":"2017-05-03T20:56:29Z","updated_at":"2017-05-03T20:56:29Z","body":"Note that for the related https://github.com/Ultimaker/Cura/issues/1785 I was not using the wheel."}}
{"actor":{"display_login":"hroncok"}}