[Render_3D] Added option to render only some components
- `show_components` like in PcbDraw
This commit is contained in:
parent
a128def73a
commit
5b19227625
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- generic filters: options to filter by PCB side
|
||||
- Diff:
|
||||
- Option to compare only the first schematic page. (See #319)
|
||||
- iBoM:
|
||||
- Support for the `offset_back_rotation` option
|
||||
- PcbDraw:
|
||||
- BMP output format
|
||||
- Image margin
|
||||
|
|
@ -22,12 +24,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Better support for variants
|
||||
- Option to control the *SVG precision* (units scale)
|
||||
- Filter expansion in `show_components` and `highlight`
|
||||
- SVG:
|
||||
- Option to control the *SVG precision* (units scale)
|
||||
- PCB_Print:
|
||||
- Option to control the *SVG precision* (units scale)
|
||||
- iBoM:
|
||||
- Support for the `offset_back_rotation` option
|
||||
- Render_3D:
|
||||
- Option to render only some components (like in PcbDraw)
|
||||
- SVG:
|
||||
- Option to control the *SVG precision* (units scale)
|
||||
|
||||
### Changed
|
||||
- Diff:
|
||||
|
|
|
|||
|
|
@ -3087,6 +3087,8 @@ Notes:
|
|||
Each step is currently 10 degrees. Only for KiCad 6.
|
||||
- **`rotate_z`**: [number=0] Steps to rotate around the Z axis, positive is clockwise.
|
||||
Each step is currently 10 degrees. Only for KiCad 6.
|
||||
- **`show_components`**: [list(string)|string=all] [none,all] List of components to draw, can be also a string for `none` or `all`.
|
||||
Unlike the `pcbdraw` output, the default is `all`.
|
||||
- **`view`**: [string='top'] [top,bottom,front,rear,right,left,z,Z,y,Y,x,X] Point of view.
|
||||
- **`zoom`**: [number=0] Zoom steps. Use positive to enlarge, get closer, and negative to reduce.
|
||||
Same result as using the mouse wheel in the 3D viewer.
|
||||
|
|
@ -4517,3 +4519,4 @@ relative paths. So you can move the new PCB file to any place, as long as the `3
|
|||
- **Chip in assembly_simple.svg**: [oNline Web Fonts](https://www.onlinewebfonts.com/)
|
||||
- **Wrench**: [Freepik - Flaticon](https://www.flaticon.es/iconos-gratis/llave-inglesa)
|
||||
- **Most icons for the navigate_results output**: The KiCad project
|
||||
- **PTV09A 3D Model**: Dmitry Levin (https://grabcad.com/dmitry.levin-6)
|
||||
|
|
|
|||
|
|
@ -1923,3 +1923,4 @@ relative paths. So you can move the new PCB file to any place, as long as the `3
|
|||
- **Chip in assembly_simple.svg**: [oNline Web Fonts](https://www.onlinewebfonts.com/)
|
||||
- **Wrench**: [Freepik - Flaticon](https://www.flaticon.es/iconos-gratis/llave-inglesa)
|
||||
- **Most icons for the navigate_results output**: The KiCad project
|
||||
- **PTV09A 3D Model**: Dmitry Levin (https://grabcad.com/dmitry.levin-6)
|
||||
|
|
|
|||
|
|
@ -1878,6 +1878,9 @@ outputs:
|
|||
# [number=0] Steps to rotate around the Z axis, positive is clockwise.
|
||||
# Each step is currently 10 degrees. Only for KiCad 6
|
||||
rotate_z: 0
|
||||
# [list(string)|string=all] [none,all] List of components to draw, can be also a string for `none` or `all`.
|
||||
# Unlike the `pcbdraw` output, the default is `all`
|
||||
show_components: all
|
||||
# [boolean=true] Show the silkscreen layers (KiCad 6)
|
||||
show_silkscreen: true
|
||||
# [boolean=true] Show the solder mask layers (KiCad 6)
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ class VariantOptions(BaseOptions):
|
|||
if extra_debug:
|
||||
logger.debug("{} 3D models that aren't for this variant".format('Enable' if enable else 'Disable'))
|
||||
self.len_disable = len(DISABLE_3D_MODEL_TEXT)
|
||||
variant_name = self.variant.name
|
||||
variant_name = self.variant.name if self.variant else 'None'
|
||||
for m in GS.get_modules_board(board):
|
||||
if extra_debug:
|
||||
logger.debug("Processing module " + m.GetReference())
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ from shutil import rmtree
|
|||
from .misc import (RENDER_3D_ERR, PCB_MAT_COLORS, PCB_FINISH_COLORS, SOLDER_COLORS, SILK_COLORS,
|
||||
KICAD_VERSION_6_0_2, MISSING_TOOL)
|
||||
from .gs import GS
|
||||
from .kiplot import exec_with_retry, add_extra_options
|
||||
from .kiplot import exec_with_retry, add_extra_options, load_sch, get_board_comps_data
|
||||
from .optionable import Optionable
|
||||
from .out_base_3d import Base3DOptions, Base3D
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
from . import log
|
||||
|
|
@ -103,6 +104,9 @@ class Render3DOptions(Base3DOptions):
|
|||
""" Clip silkscreen at via annuli (KiCad 6) """
|
||||
self.subtract_mask_from_silk = True
|
||||
""" Clip silkscreen at solder mask edges (KiCad 6) """
|
||||
self.show_components = Optionable
|
||||
""" *[list(string)|string=all] [none,all] List of components to draw, can be also a string for `none` or `all`.
|
||||
Unlike the `pcbdraw` output, the default is `all` """
|
||||
super().__init__()
|
||||
self._expand_ext = 'png'
|
||||
|
||||
|
|
@ -147,6 +151,17 @@ class Render3DOptions(Base3DOptions):
|
|||
view = self._views.get(self.view, None)
|
||||
if view is not None:
|
||||
self.view = view
|
||||
# List of components
|
||||
self._show_all_components = False
|
||||
if isinstance(self.show_components, str):
|
||||
if self.show_components == 'all':
|
||||
self._show_all_components = True
|
||||
self.show_components = set()
|
||||
elif isinstance(self.show_components, type):
|
||||
# Default is all
|
||||
self._show_all_components = True
|
||||
else: # a list
|
||||
self.show_components = set(self.show_components)
|
||||
self._expand_id += '_'+self._rviews.get(self.view)
|
||||
|
||||
def add_step(self, cmd, steps, ops):
|
||||
|
|
@ -194,6 +209,22 @@ class Render3DOptions(Base3DOptions):
|
|||
if not self.subtract_mask_from_silk:
|
||||
cmd.append('--dont_substrack_mask_from_silk')
|
||||
|
||||
def apply_show_components(self):
|
||||
if self._show_all_components:
|
||||
# Don't change anything
|
||||
return
|
||||
# The user specified a list of components, we must remove the rest
|
||||
if not self._comps:
|
||||
# No variant or filter applied
|
||||
# Load the components
|
||||
load_sch()
|
||||
self._comps = GS.sch.get_components()
|
||||
get_board_comps_data(self._comps)
|
||||
# If the component isn't listed by the user make it DNF
|
||||
for c in self._comps:
|
||||
if c.ref not in self.show_components:
|
||||
c.fitted = False
|
||||
|
||||
def run(self, output):
|
||||
super().run(output)
|
||||
if GS.ki6 and GS.kicad_version_n < KICAD_VERSION_6_0_2:
|
||||
|
|
@ -206,6 +237,7 @@ class Render3DOptions(Base3DOptions):
|
|||
'3d_view', '--output_name', output]
|
||||
self.add_options(cmd)
|
||||
# The board
|
||||
self.apply_show_components()
|
||||
board_name = self.filter_components()
|
||||
cmd.extend([board_name, os.path.dirname(output)])
|
||||
cmd, video_remove = add_extra_options(cmd)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: render_list
|
||||
comment: "Render with only some components"
|
||||
type: render_3d
|
||||
options:
|
||||
width: 800
|
||||
height: 600
|
||||
orthographic: true
|
||||
zoom: 4
|
||||
show_components: ["RV1", "RV2", "U1", "U2", "U3"]
|
||||
ray_tracing: true
|
||||
background1: "#ff70b7"
|
||||
background2: "#ff70b7"
|
||||
# background1: "#ffffff"
|
||||
# background2: "#ffffff"
|
||||
Loading…
Reference in New Issue