4
$\begingroup$

In the KiCad project, we ship 3D models of electronic components so people can do a rendered or raytraced preview of their PCB before sending it off to manufacture.

Several of the models are rather repetitive, for example the models for pin headers exist in 1x1, 1x2, 1x3, ... 1x30, 2x1, 2x2, 2x3, ..., 2x30, 3x1, 3x2, 3x3, ..., 3x30 variants, and each of these for multiple common configurations of pin pitch and thickness.

These are currently generated with a script, which generates a lot of output, and is difficult to maintain.

Is there a way in Blender to build a parametric model, ideally in a way that remains editable? Typical parameters would be distances, loop counts, texts and colors (e.g. for rings on resistors).

OpenSCAD comes close to what we need, but is difficult to use and doesn't generate material information, which makes the models unusable for rendering.

$\endgroup$
12
  • $\begingroup$ Simple answer is yes. For example add a cylinder, change the amount of verts in ring and depth. $\endgroup$
    – batFINGER
    Dec 16, 2019 at 15:25
  • $\begingroup$ @batFINGER, to clarify, we need to be able to set the parameters when importing the model into another tool, so we'd have to be able to use a variable name there, and somehow find out from our tool what variables exist. $\endgroup$ Dec 16, 2019 at 15:31
  • $\begingroup$ Can you provide an example of the kind of data you want to start from? Is it geometry or a text description of the board? $\endgroup$
    – Ed Tate
    Dec 20, 2019 at 1:31
  • $\begingroup$ @EdTate, we usually have a mechanical drawing for the geometry, with a table on how different variants differ (e.g. pin count, pin thickness, pin pitch). The answer by Martynas Žiemys gets one of the problems, pin count of a header, right, but we need to be able to fill in the actual pin count when we load the model (which we currently do through OCC/OCE) so we don't have to ship each variant as a separate file. Some other models need more than simple repetition, e.g. ICs with different pin counts also need the package itself elongated. $\endgroup$ Dec 20, 2019 at 11:03
  • $\begingroup$ Can the exporter generate a text file describing the geometry wanted and the location? $\endgroup$
    – Ed Tate
    Dec 21, 2019 at 2:48

1 Answer 1

1
$\begingroup$

You can use modifiers like for example Array modifier to make it easier to model:

enter image description here

However if you wanted to have more control and trully parametric models, you would probably need to script the creation with Python(See Templates menu -> Python -> Addon Add Object in the Text Editor). Is it worth the trouble? It depends on what you are after. If you just need the parts modelled, it will be easier to model them and making them parametric will be extra work.

$\endgroup$
2
  • $\begingroup$ The goal is to stop shipping 5 GiB of prebuilt models in STEP files that only differ in parameters, and generate the required model on the fly from the template when it is first used -- for that the program importing the model needs to be able to specify the numbers later. $\endgroup$ Dec 16, 2019 at 15:53
  • $\begingroup$ Then the answer is: it is possible to use Blender's Python API for generating 3d models proceedurally. Blender has bmesh Python module that has tools for working with geometry that might make things easier than programming/scripting from scratch. You can also have a look at Animation Nodes. $\endgroup$ Dec 16, 2019 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .