**这是本文档旧的修订版!**
3D模型的安装、获取和关联
KiCad的3D查看器可以显示封装的三维效果,当然前提是已经为这个封装关联了3D模型。3D模型的文件比较大,因此在安装KiCad软件的时候,缺省是不安装的,可以后期根据自己的需要按照向导来安装。
官方库的下载和更新
如果要安装, 启动Pcbnew、点击“首选项”按钮,选中“3D模型库添加向导“。
图。。。。添加向导界面
这个过程会问你几个问题 - 哪个3D库需要安装,安装在哪个目录下?
我选择安装在自己的KiCad库目录下(见图。。。)
图: 确定要安装的3D模型库的目录
选中所有想安装的库。
图: 选择要安装的3D库
下一步,向导会汇总它要下载的所有的库 - 现有的库会被更新,同时安装新的库
图: 显示所有要下载的库.
点击“完成”开始下载。如果你的网速不够快,可能需要在夜间下载,因为文件实在太大,它要花费好几个小时的时间。
图: 下载可能需要几个小时的时间
当然,不是所有的封装都有了关联的3D模型库,这需要你通过其它渠道去找一下,实在找不到的,可以自己来创建。
第三方3D资源库的下载
The 3D viewer in Pcbnew provides an excellent way to visualise your board before you send it out for manufacturing. Out of the box, the 3D viewer will show you what your board will look like, and can render the PCB itself, the traces, copper fills and all pads and holes. The 3D Viewer can also visualise the components that will eventually be attached on the board, so that you can have a complete picture of the final product. KiCad ships with a comprehensive library of 3D shapes as a seperate download (because of its size). See recipe ”55. How to install 3D shapes” for more information on how to do that. However comprehensive this library may be, there will always components on your board that don’t have a matching 3D shape available in KiCad’s library. In those cases, you have two options: 1. Look for a matching shape in a 3rd party provider. 2. Make a matching shape yourself. In this recipe, you will learn how to find and import a 3D shape from one such provider, Grabcad.com. You can follow the same process to import shapes from other providers. In a separate recipe, you will also learn how to create your own shapes. To demonstrate how to import a 3D shape, we’ll work on the PCB from Project 1 of this book. Our starting point is the end of Project 1, when the final PCB looks like this:
It already looks good, with most of the components having a match in the KiCad 3D shape library. But, two components don’t. The barrel connector and the slide switch have no match. There are many contributed 3D shapes and shape libraries available on the Internet. In this recipe, we’ll use grabcad.com to find the missing shapes for this PCB. Let’s start with the barrel connector. Go to grabcad.com, and use the search bar to search for this shape. It may take a few attempts, because the naming of many components are not standardised or using. The barrel connector can be referred to as “DC power plug” or “DC power supply connector” or “EJ5035 connector”, etc. After a few attempts, I found the exact shape I was looking for. You can also find it at https://grabcad.com/library/ej503b-connector-1. Once you found the shape you need, look for the downloadable file with the “.stp“ extension. An .stp file, pronounced “STEP”, is a commonly use data exchange format for representing 3D objects. The 3D viewer in KiCad can work with this file format. Figure 57.2: The .stp file contains the data for our 3D shape Download the EJ503B-ND.stp file. I save it in a 3D shapes folder in my project directory, so it is easy to find later. Next, start Pcbnew if not already started. Hover your mouse over the barrel connector footprint, and bring up the footprint properties window by
pressing the “E” key (or right click to get the context menu, and select Properties). In the Properties window, click on the 3D Settings tab.
Before we assign a new 3D shape, delete the existing one by selecting the only row in the 3D Models pane, and clicking on the rubbish bin button. Even though there is an assignment, this specific wrl file does not exist on my computer. Let’s add the new 3D shape. Click on the folder button right under the 3D Models pane, and navigate your file system to the location where you saved the STP file earlier. Click on the STP file, and the viewer will show the 3D shape in the right pane.
Figure 57.4: We’ll select this 3D shape; its preview confirms this is the model I need. Click OK to accept this selection, and you’ll go back to the Footprint Properties window. As you can see, the 3D shape is not visible in the preview, but it is not in its correct place.
Figure 57.5: The new 3D shape is part of the model, but it is out of place. Now, we must manually position the 3D shape over the PCB in the way we want it to appear in the final board rendering. Use the Scale, Rotation and Offset controls to do that. With a bit of effort, the final 3D model for this footprint will look like this: Figure 57.6: The new 3D shape is part of the model, but it is out of place. Be sure to inspect the model from various angles to make sure everything is aligned. Also look at it from the bottom to ensure that the pins and the holes are aligned. When the alignment is complete, click on “Ok” to commit the changes. Let’s have a look at the 3D rendering of the full PCB. Bring up the 3D viewer. It should look like this: Figure 57.7: The barrel connector 3D shape appears in the PCB 3D viewer. Much better, ins’t it? There one more footprint without a 3D shape, the slide switch. You can find a shape for this footprint also in grabcad.com. Go to this page: https: grabcad.com/library/small-slide-switch-1, or search for “small slide switch”. Follow the exact same process to associate the slide switch footprint with this shape. To make the shape fit well, I also had to adjust the X-scale value. Figure 57.8: The slide switch 3D shape appears in the PCB 3D viewer. Click OK to commit these changes, and bring up the 3D viewer for the PCB. Figure 57.9: The completed PCB, rendered in the 3D viewer, with all component models. This is much better. All of the footprints now have their 3D shapes appearing in the 3D rendering of the PCB. For most footprints, you should have no trouble finding an existing 3D shape that can fit your footprint perfectly after a small amount of tweaking its position and scale. ### 3D模型的关联