Added support for 3D View rotations (KiCad 6 only)

This commit is contained in:
Salvador E. Tropea 2022-03-29 15:49:33 -03:00
parent 3c13ae1ccb
commit b58430a8ea
3 changed files with 34 additions and 5 deletions

View File

@ -1877,6 +1877,12 @@ Next time you need this list just use an alias, like this:
- `orthographic`: [boolean=false] Enable the orthographic projection mode (top view looks flat).
- `output`: [string='%f-%i%I%v.%x'] Name for the generated image file (%i='3D_$VIEW' %x='png'). Affected by global options.
- `ray_tracing`: [boolean=false] Enable the ray tracing. Much better result, but slow, and you'll need to adjust `wait_rt`.
- `rotate_x`: [number=0] Steps to rotate around the X axis, positive is clockwise.
Each step is currently 10 degrees. Only for KiCad 6.
- `rotate_y`: [number=0] Steps to rotate around the Y axis, positive is clockwise.
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.
- `silk`: [string='#d5dce4'] Color for the silk screen.
- `solder_mask`: [string='#208b47'] Color for the solder mask.
- `solder_paste`: [string='#808080'] Color for the solder paste.

View File

@ -1328,6 +1328,15 @@ outputs:
output: '%f-%i%I%v.%x'
# [boolean=false] Enable the ray tracing. Much better result, but slow, and you'll need to adjust `wait_rt`
ray_tracing: false
# [number=0] Steps to rotate around the X axis, positive is clockwise.
# Each step is currently 10 degrees. Only for KiCad 6
rotate_x: 0
# [number=0] Steps to rotate around the Y axis, positive is clockwise.
# Each step is currently 10 degrees. Only for KiCad 6
rotate_y: 0
# [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
# [string='#d5dce4'] Color for the silk screen
silk: '#d5dce4'
# [string='#208b47'] Color for the solder mask

View File

@ -57,6 +57,15 @@ class Render3DOptions(Base3DOptions):
self.move_y = 0
""" Steps to move in the Y axis, positive is up.
Just like pressing the up arrow in the 3D viewer """
self.rotate_x = 0
""" Steps to rotate around the X axis, positive is clockwise.
Each step is currently 10 degrees. Only for KiCad 6 """
self.rotate_y = 0
""" Steps to rotate around the Y axis, positive is clockwise.
Each step is currently 10 degrees. Only for KiCad 6 """
self.rotate_z = 0
""" Steps to rotate around the Z axis, positive is clockwise.
Each step is currently 10 degrees. Only for KiCad 6 """
self.ray_tracing = False
""" Enable the ray tracing. Much better result, but slow, and you'll need to adjust `wait_rt` """
self.wait_ray_tracing = -600
@ -119,13 +128,17 @@ class Render3DOptions(Base3DOptions):
self.view = view
self._expand_id += '_'+self._rviews.get(self.view)
def add_step(self, cmd, steps, ops):
if steps:
cmd.extend([ops, str(steps)])
def run(self, output):
super().run(output)
if GS.ki6() and GS.kicad_version_n < KICAD_VERSION_6_0_2:
logger.error("3D Viewer not supported for KiCad 6.0.0/1\n"
"Please upgrade KiCad to 6.0.2 or newer")
exit(MISSING_TOOL)
check_script(CMD_PCBNEW_3D, URL_PCBNEW_3D, '1.6.5' if GS.ki6() else '1.5.14')
check_script(CMD_PCBNEW_3D, URL_PCBNEW_3D, '1.6.8')
# Base command with overwrite
cmd = [CMD_PCBNEW_3D, '--rec_w', str(self.width+2), '--rec_h', str(self.height+85),
'3d_view', '--output_name', output]
@ -138,10 +151,11 @@ class Render3DOptions(Base3DOptions):
cmd.append('--no_smd')
for color, option in self._colors.items():
cmd.extend(['--'+option, getattr(self, color)])
if self.move_x:
cmd.extend(['--move_x', str(self.move_x)])
if self.move_y:
cmd.extend(['--move_y', str(self.move_y)])
self.add_step(cmd, self.move_x, '--move_x')
self.add_step(cmd, self.move_y, '--move_y')
self.add_step(cmd, self.rotate_x, '--rotate_x')
self.add_step(cmd, self.rotate_y, '--rotate_y')
self.add_step(cmd, self.rotate_z, '--rotate_z')
if self.zoom:
cmd.extend(['--zoom', str(self.zoom)])
if self.wait_ray_tracing != 5: