Closed VanessaE closed 6 months ago
Using pip to install packages globally has been strongly discouraged for a long time now (a few years I guess). In fact, the way I understand it, even pip itself shouldn't be installed globally. One is supposed to use a virtual environment -- but Blender doesn't use a typical virtual environment at all (probably because it is its own environment to begin with).
Okay... well, it's unclear what would happen if I clicked the "install" button there (would it be global? will it need sudo? or would be it be local? if that's the case, where would the files go?), so I'll exit Blender and head back to the command line.
The modules will be installed into a site-packages
folder inside the pcb2blender_importer
addon directory. The path to said directory will then be prepended to sys.path
during addon initialization. That's the best I could come up with (as you figured, Blender doesn't really support venvs).
(Blender should (some distros (for whatever reason) deviate from this) also come with it's own Python installation. If your distro doesn't do this, that could cause problems).
Anyways.
... seems to be related to my override of Blender's integrated X3D/VRML2
importer. Make sure it's present and enabled.
The modules will be installed into a
site-packages
folder inside thepcb2blender_importer
addon directory. The path to said directory will then be prepended tosys.path
during addon initialization. That's the best I could come up with (as you figured, Blender doesn't really support venvs).
Noted.
(Blender should (some distros (for whatever reason) deviate from this) also come with it's own Python installation. If your distro doesn't do this, that could cause problems).
Though there's probably a recent-ish version in Debian Bookworm's repositories, I actually use the zipped build distributed directly by the Blender team. Folks call Debian "stale" for a reason. 😛
The actual error you are getting
... seems to be related to my override of Blender's integrated
X3D/VRML2
importer. Make sure it's present and enabled.
Ah hah, enabling that made the importer plugin behave at least enough to try to use it.
However, when I follow the readme to specify the board's bounds in Kicad, then export it, I get a 2.7 MB file, so that seems legit:
If I try to import that file into Blender, it hangs for several seconds, then I get a ginormous wireframe of one of the components along with a really tiny board:
The board must be exporting with meter resolution but the importer apparently expects millimeters, as the size is off by exactly 1000x. Unfortunately, without components on it, it's not directly usable:
And I get this error after it finishes:
Python: Traceback (most recent call last):
File "/home/vanessa/.config/blender/3.6/scripts/addons/pcb2blender_importer/importer.py", line 205, in execute
if (pcb := self.import_pcb3d(context, filepath)) == {"CANCELLED"}:
File "/home/vanessa/.config/blender/3.6/scripts/addons/pcb2blender_importer/importer.py", line 345, in import_pcb3d
bpy.ops.pcb2blender.import_x3d(
File "/home/data/Archives/Software/Linux/blender-related/blender-3.6.1-linux-x64/3.6/scripts/modules/bpy/ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Error: Python: Traceback (most recent call last):
File "/home/vanessa/.config/blender/3.6/scripts/addons/pcb2blender_importer/importer.py", line 1011, in execute
result = import_x3d.load(context, self.filepath, global_matrix=matrix)
File "/home/data/Archives/Software/Linux/blender-related/blender-3.6.1-linux-x64/3.6/scripts/addons/io_scene_x3d/import_x3d.py", line 3629, in load
load_web3d(context, filepath,
File "/home/data/Archives/Software/Linux/blender-related/blender-3.6.1-linux-x64/3.6/scripts/addons/io_scene_x3d/import_x3d.py", line 3528, in load_web3d
importShape(bpycollection, node, ancestry, global_matrix)
File "/home/data/Archives/Software/Linux/blender-related/blender-3.6.1-linux-x64/3.6/scripts/addons/io_scene_x3d/import_x3d.py", line 3142, in importShape
bpydata = geom_fn(geom, ancestry)
File "/home/data/Archives/Software/Linux/blender-related/blender-3.6.1-linux-x64/3.6/scripts/addons/io_scene_x3d/import_x3d.py", line 1894, in importMesh_IndexedFaceSet
if len(points) >= 2 * len(index): # Need to cull
TypeError: object of type 'NoneType' has no len()
Location: /home/data/Archives/Software/Linux/blender-related/blender-3.6.1-linux-x64/3.6/scripts/modules/bpy/ops.py:113
Ah hah, enabling that made the importer plugin behave at least enough to try to use it.
Great!
However, when I follow the readme to specify the board's bounds in Kicad, then export it, I get a 2.7 MB file, so that seems legit:
Note: You don't actually have to specify bounds for single board designs (it shouldn't hurt but it actually sometimes does 😅 ).
If I try to import that file into Blender, it hangs for several seconds, then I get a ginormous wireframe of one of the components along with a really tiny board: The board must be exporting with meter resolution but the importer apparently expects millimeters, as the size is off by exactly 1000x. Unfortunately, without components on it, it's not directly usable:
What you are seing here doesn't really matter (it's only intermediate), as the importer is crashing during operation.
The X3D/VRML importer seems to fail importing when importing that model (the micro SD card slot or whatever that is). Either that model is broken/invalid or there's a bug in the X3D/VRML importer (probably both). There's not much I can do about that, you can possibly try editing/fixing that model or just remove it.
Oh also, out of curiosity, was the X3D/VRML importer addon not enabled by default with your debian installation?
Note: You don't actually have to specify bounds for single board designs (it shouldn't hurt but it actually sometimes does 😅 ).
Nope, I tried that first, it could not detect the board without my marking the bounds with those text items.
What you are seing here doesn't really matter (it's only intermediate), as the importer is crashing during operation.
That would explain the lack of models on the board.
Either that model is broken/invalid or there's a bug in the X3D/VRML importer (probably both). There's not much I can do about that
Well, I found a workaround already (days ago) that doesn't involve your plugins: export the board to STEP, then use Freecad to import it:
So the SD card slot isn't broken, though there was some odd warning about "non-unity scaling" of that model when I exported the board to STEP from Kicad.
Then I had Freecad export that to STL and brought it into Blender. STL of course loses all the materials and groupings and a lot of details about the mesh, but it was enough to at least have something accurate to model my project against.
I can probably combine that with this partially-imported board from your plugins to at least improve my model's general appearance (e.g. to get the silk, pads/vias/holes, etc). I'll putter around with that more later on.
Oh also, out of curiosity, was the X3D/VRML importer addon not enabled by default with your debian installation?
It was disabled by default.
Nope, I tried that first, it could not detect the board without my marking the bounds with those text items.
Yeah ... the exporter UI is/was kind of not ideal. It says it doesn't detect any boards, but it will still just default to exporting everything.
Well, I found a workaround already (days ago) that doesn't involve your plugins: export the board to STEP, then use Freecad to import it.
Yeah that's one manual way to do it (getting the models into Blender is the easy part really). Achieving a result that's visually similar to what this addon provides though, will probably take quite a lot of additional time (that's why it exists 😅 ).
If you are interested, I did a quick comparison of the KiCad 3D Viewer, a vanilla VRML Blender import with default materials and pcb2blender a couple of weeks ago.
I can probably combine that with this partially-imported board from your plugins to at least improve my model's general appearance (e.g. to get the silk, pads/vias/holes, etc). I'll putter around with that more later on.
Also note: It's not really partially-imported either, as most of the magic happens after importing all the basic models. You'll really get a much better result if you disable tthe model causing the issue before exporting.
Yeah that's one manual way to do it (getting the models into Blender is the easy part really). Achieving a result that's visually similar to what this addon provides though, will probably take quite a lot of additional time (that's why it exists 😅 ).
Yeah I kinda got frustrated by the end, but this is what I eventually ended up with originally:
Combined with your importer's efforts and using my own materials yields this:
I can live with that. 🙂
Release v2.7 seems the last version that's supposed to work with Blender 3.6[*] as far as I can see, but I just can't seem to install this fully/properly.
All of the following were done with a freshly extracted Blender build, from the official Linux
.xz
archive.I downloaded your v2.7 release zip and installed it through the add-ons manager as one does with any other addon. Nothing notable in the terminal, just one line saying the add-on was installed.
After installing, I was presented with this when I tried to enable it:
Using
pip
to install packages globally has been strongly discouraged for a long time now (a few years I guess). In fact, the way I understand it, evenpip
itself shouldn't be installed globally. One is supposed to use a virtual environment -- but Blender doesn't use a typical virtual environment at all (probably because it is its own environment to begin with).Okay... well, it's unclear what would happen if I clicked the "install" button there (would it be global? will it need sudo? or would be it be local? if that's the case, where would the files go?), so I'll exit Blender and head back to the command line.
My system (Debian Bookworm) uses 3.11 normally, and Blender 3.6 ships with Python 3.10, so maybe if use that version directly, it'll just download and "install"
pip
locally to the Blender folder. Assuming that, I downloaded theget-pip.py
script from the main site, and ran it thus:Okay, I suppose that output looks right. As above, your add-on said I need
skia-python
andpillow
, whatever those are. Okay, let's use that newly-installedpip
:That seems right. Let's run Blender:
Eh, no. That isn't right.
Within Blender's add-ons manager,
pcb2blender
shows that it's enabled, but there is no import option for anything related. Makes sense, given that error.If I disable the add-on, I see
addon_utils.disable: pcb2blender_importer not disabled
appear in the terminal. If I then try to re-enable it, a repeat of the above error is printed to the terminal, and also into a Blender pop-up.There is no obvious path forward. All I can do now is remove the add-on.
Okay, I'll try this whole series of steps again, starting with a freshly-extracted tarball, only THIS time, I'll run Blender only long enough to "initialize", then close it and install
pip
and those two packages *before* installing your add-on:Looks the same as before, but I suppose it should.
Now fire-up Blender and install your add-on:
Failed again.
What did I miss?
Sorry if this comes off a little coarse. I just spent the last few hours arguing with KiCAD -- a program I have never used (I last used Lepton/gEDA) -- to get the PCB in question into a useful state, an act that should have taken only a few minutes, and discovering a whole new level of frustration in the process. That's all before I even came across this project.
Related: #13, #14
[*] I can't use Blender 4.x due to an incompatibility with one of my projects.