linkcad.controller
High-level conversion workflow controller. Use this when you need the full conversion wizard state machine (select formats, set options, read, apply tools, write) rather than driving linkcad.conv directly.
from linkcad.v1.controller import ( ConversionController, ConversionState, ControllerEvent, IControllerListener, ProgressInfo,)Classes
ConversionController
Orchestrates the multi-step conversion workflow used by the LinkCAD conversion wizard.
from linkcad.v1.controller import ConversionController
ctrl = ConversionController()ConversionController.import_format = "GDSII"ConversionController.export_format = "DXF"ctrl.selected_input_files = ["/data/design.gds"]ConversionController.output_file = "/data/design.dxf"
ctrl.start_read()dwg = ctrl.current_drawingif dwg is None: raise RuntimeError("Import produced no drawing")
ctrl.start_write()print(ctrl.current_state)Format selection and the output path are process-wide state in the engine, so import_format, export_format and output_file are static properties: assign them on the class. Reading them from an instance works too, and gives the same value.
| Property / Method | Description |
|---|---|
ConversionController() | Create a new controller instance |
ConversionController.import_format / .export_format | Format names (e.g. "GDSII"); static, assignable |
ConversionController.output_file | Output file path; static, assignable |
ctrl.selected_input_files | List of input file paths; assignable |
ctrl.set_import_options(options_json) / ctrl.set_export_options(options_json) | Apply options as a JSON string |
ctrl.tools_enabled | Whether tools run between reading and writing; assignable |
ctrl.configure_tools(tools_config) | Configure the tool stage from JSON |
ctrl.batch_mode | Batch conversion mode; assignable |
ctrl.start_read() | Start reading the input file(s) |
ctrl.start_write() | Start writing the output file |
ctrl.start_batch() | Start a batch conversion |
ctrl.finish_operation(success) | Mark the current operation as finished |
ctrl.cancel_current_operation() | Cancel the operation in flight |
ctrl.operation_in_progress | True while an operation is running |
ctrl.next() / ctrl.back() / ctrl.reset() | Move through the workflow states |
ctrl.can_go_next / ctrl.can_go_back | Whether navigation is possible |
ctrl.current_state | Current ConversionState |
ctrl.current_drawing | The loaded Drawing, or None |
ctrl.current_progress | Current ProgressInfo |
ctrl.import_log | Import log, as an IEventLogReader |
ctrl.export_log | Export log, as an IEventLog |
ctrl.conversions | The underlying Conversions collection — see linkcad.conv |
ctrl.add_listener(listener) / ctrl.remove_listener(listener) | Attach or detach an IControllerListener |
set_import_options() and set_export_options() stay methods: the controller hands the JSON straight to the plugin and keeps nothing to read back, and a property with no getter is not a property.
ConversionState
Enum naming each page of the conversion wizard.
| Value | Description |
|---|---|
ConversionState.Begin | Initial state |
ConversionState.SelectFormat | Import and export format selection |
ConversionState.ImportOptions | Import options page |
ConversionState.ExportOptionsPre | Export options shown before reading |
ConversionState.ReadFile | Reading the input file(s) |
ConversionState.ApplyTools | Applying geometry tools |
ConversionState.ReadLog | Import log review |
ConversionState.OpenPolys | Open-polyline handling |
ConversionState.BatchTools | Tool configuration for batch runs |
ConversionState.Structure | Cell/layer structure page |
ConversionState.ExportOptionsPost | Export options shown after reading |
ConversionState.SelectBatchFiles | Batch file selection |
ConversionState.ConvertBatchFiles | Batch conversion in progress |
ConversionState.WriteFile | Writing the output file |
ConversionState.WriteLog | Export log review |
ConversionState.Summary | Summary page |
ConversionState.End | Workflow complete |
ControllerEvent
Enum of the notifications a controller emits.
| Value | Description |
|---|---|
ControllerEvent.StateChanged | The workflow moved to a different state |
ControllerEvent.PageActivated | A wizard page became active |
ControllerEvent.ProgressUpdated | Progress information changed |
ControllerEvent.LogUpdated | A log gained entries |
ControllerEvent.DrawingChanged | The current drawing was replaced |
ControllerEvent.OperationFinished | An operation completed |
ControllerEvent.OperationCancelled | An operation was cancelled |
ControllerEvent.ErrorOccurred | An error was reported |
ProgressInfo
Progress snapshot returned by ctrl.current_progress.
| Property | Description |
|---|---|
percentage | Progress percentage (0-100) |
current_operation | Description of the current step |
current_file | File being processed |
current_file_index | Index of the current file |
total_files | Number of files in the job |
IControllerListener
Subclass this to receive controller notifications. Every method must be overridden.
from linkcad.v1.controller import ConversionController, IControllerListener
class Watcher(IControllerListener): def on_state_changed(self, new_state): print(f"state: {new_state}") def on_page_activated(self, page): pass def on_progress_updated(self, progress): print(f"{progress.percentage}%") def on_log_updated(self): pass def on_drawing_about_to_be_cleared(self, drawing): pass def on_drawing_changed(self, drawing): pass def on_operation_finished(self, success): print(f"finished: {success}") def on_operation_cancelled(self): pass def on_error_occurred(self, message): print(f"error: {message}")
ctrl = ConversionController()watcher = Watcher()ctrl.add_listener(watcher)| Method | Called when |
|---|---|
on_state_changed(new_state) | The workflow state changes |
on_page_activated(page) | A wizard page is activated |
on_progress_updated(progress) | Progress is updated |
on_log_updated() | A log is updated |
on_drawing_about_to_be_cleared(drawing) | Right before the current drawing is discarded |
on_drawing_changed(drawing) | The drawing changes |
on_operation_finished(success) | An operation finishes |
on_operation_cancelled() | An operation is cancelled |
on_error_occurred(message) | An error occurs |