diff --git a/CHANGELOG.md b/CHANGELOG.md index 107f2258..43dd22ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Check for value and fields/properties. - SCH print: - Support for title change +- VRML: + - Option to use the auxiliary origin as reference. (#420) ### Fixed - Makefile: don't skip all preflights on each run, just the ones we generate diff --git a/README.md b/README.md index 589a421d..7e0e0cb0 100644 --- a/README.md +++ b/README.md @@ -4770,8 +4770,10 @@ Notes: - `pre_transform`: [string|list(string)='_none'] Name of the filter to transform fields before applying other filters. A short-cut to use for simple cases where a variant is an overkill. - `ref_units`: [string='millimeters'] [millimeters,inches'] Units for `ref_x` and `ref_y`. - - `ref_x`: [number=0] X coordinate to use as reference when `use_pcb_center_as_ref` is disabled. - - `ref_y`: [number=0] Y coordinate to use as reference when `use_pcb_center_as_ref` is disabled. + - `ref_x`: [number=0] X coordinate to use as reference when `use_pcb_center_as_ref` and `use_pcb_center_as_ref` are disabled. + - `ref_y`: [number=0] Y coordinate to use as reference when `use_pcb_center_as_ref` and `use_pcb_center_as_ref` are disabled. + - `use_aux_axis_as_origin`: [boolean=false] Use the auxiliary axis as origin for coordinates. + Has more precedence than `use_pcb_center_as_ref`. - `use_pcb_center_as_ref`: [boolean=true] The center of the PCB will be used as reference point. When disabled the `ref_x`, `ref_y` and `ref_units` will be used. - `variant`: [string=''] Board variant to apply. diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 6964cde8..8a8f896c 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -3418,13 +3418,16 @@ outputs: pre_transform: '_none' # [string='millimeters'] [millimeters,inches'] Units for `ref_x` and `ref_y` ref_units: 'millimeters' - # [number=0] X coordinate to use as reference when `use_pcb_center_as_ref` is disabled + # [number=0] X coordinate to use as reference when `use_pcb_center_as_ref` and `use_pcb_center_as_ref` are disabled ref_x: 0 - # [number=0] Y coordinate to use as reference when `use_pcb_center_as_ref` is disabled + # [number=0] Y coordinate to use as reference when `use_pcb_center_as_ref` and `use_pcb_center_as_ref` are disabled ref_y: 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=false] Use the auxiliary axis as origin for coordinates. + # Has more precedence than `use_pcb_center_as_ref` + use_aux_axis_as_origin: false # [boolean=true] The center of the PCB will be used as reference point. # When disabled the `ref_x`, `ref_y` and `ref_units` will be used use_pcb_center_as_ref: true diff --git a/kibot/out_vrml.py b/kibot/out_vrml.py index 92321534..1b9c9cc0 100644 --- a/kibot/out_vrml.py +++ b/kibot/out_vrml.py @@ -36,10 +36,13 @@ class VRMLOptions(Base3DOptionsWithHL): self.use_pcb_center_as_ref = True """ The center of the PCB will be used as reference point. When disabled the `ref_x`, `ref_y` and `ref_units` will be used """ + self.use_aux_axis_as_origin = False + """ Use the auxiliary axis as origin for coordinates. + Has more precedence than `use_pcb_center_as_ref` """ self.ref_x = 0 - """ X coordinate to use as reference when `use_pcb_center_as_ref` is disabled """ + """ X coordinate to use as reference when `use_pcb_center_as_ref` and `use_pcb_center_as_ref` are disabled """ self.ref_y = 0 - """ Y coordinate to use as reference when `use_pcb_center_as_ref` is disabled """ + """ Y coordinate to use as reference when `use_pcb_center_as_ref` and `use_pcb_center_as_ref` are disabled """ self.ref_units = 'millimeters' """ [millimeters,inches'] Units for `ref_x` and `ref_y` """ self.model_units = 'millimeters' @@ -75,9 +78,14 @@ class VRMLOptions(Base3DOptionsWithHL): cmd = [command, 'export_vrml', '--output_name', os.path.basename(name), '-U', self.model_units] if self.dir_models: cmd.extend(['--dir_models', self.dir_models]) - if not self.use_pcb_center_as_ref or GS.ki5: + if not self.use_pcb_center_as_ref or GS.ki5 or self.use_aux_axis_as_origin: + if self.use_aux_axis_as_origin: + offset = GS.get_aux_origin() + x = GS.to_mm(offset.x) + y = GS.to_mm(offset.y) + units = 'millimeters' # KiCad 5 doesn't support using the center, we emulate it - if self.use_pcb_center_as_ref and GS.ki5: + elif self.use_pcb_center_as_ref and GS.ki5: x, y = self.get_pcb_center() units = 'millimeters' else: