feat(project): add SetTextVariables API and CLI command
This commit is contained in:
parent
fff70f61c1
commit
0e8217fd8f
|
|
@ -44,6 +44,7 @@ Deferred manual/runtime verification (implemented after 2026-02-20 while user un
|
||||||
- `DeleteItems`
|
- `DeleteItems`
|
||||||
- `ParseAndCreateItemsFromString`
|
- `ParseAndCreateItemsFromString`
|
||||||
- `SetNetClasses`
|
- `SetNetClasses`
|
||||||
|
- `SetTextVariables`
|
||||||
|
|
||||||
## KiCad v10 RC1.1 API Completion Matrix
|
## KiCad v10 RC1.1 API Completion Matrix
|
||||||
|
|
||||||
|
|
@ -65,10 +66,10 @@ Legend:
|
||||||
| --- | ---: | ---: | ---: |
|
| --- | ---: | ---: | ---: |
|
||||||
| Common (base) | 6 | 6 | 100% |
|
| Common (base) | 6 | 6 | 100% |
|
||||||
| Common editor/document | 23 | 23 | 100% |
|
| Common editor/document | 23 | 23 | 100% |
|
||||||
| Project manager | 5 | 4 | 80% |
|
| Project manager | 5 | 5 | 100% |
|
||||||
| Board editor (PCB) | 22 | 20 | 91% |
|
| Board editor (PCB) | 22 | 20 | 91% |
|
||||||
| Schematic editor (dedicated proto commands) | 0 | 0 | n/a |
|
| Schematic editor (dedicated proto commands) | 0 | 0 | n/a |
|
||||||
| **Total** | **56** | **53** | **95%** |
|
| **Total** | **56** | **54** | **96%** |
|
||||||
|
|
||||||
### Common (base)
|
### Common (base)
|
||||||
|
|
||||||
|
|
@ -117,7 +118,7 @@ Legend:
|
||||||
| `SetNetClasses` | Implemented | `KiCadClient::set_net_classes_raw`, `KiCadClient::set_net_classes` |
|
| `SetNetClasses` | Implemented | `KiCadClient::set_net_classes_raw`, `KiCadClient::set_net_classes` |
|
||||||
| `ExpandTextVariables` | Implemented | `KiCadClient::expand_text_variables_raw`, `KiCadClient::expand_text_variables` |
|
| `ExpandTextVariables` | Implemented | `KiCadClient::expand_text_variables_raw`, `KiCadClient::expand_text_variables` |
|
||||||
| `GetTextVariables` | Implemented | `KiCadClient::get_text_variables_raw`, `KiCadClient::get_text_variables` |
|
| `GetTextVariables` | Implemented | `KiCadClient::get_text_variables_raw`, `KiCadClient::get_text_variables` |
|
||||||
| `SetTextVariables` | Not yet | - |
|
| `SetTextVariables` | Implemented | `KiCadClient::set_text_variables_raw`, `KiCadClient::set_text_variables` |
|
||||||
|
|
||||||
### Board editor (PCB)
|
### Board editor (PCB)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,12 @@ List text variables for current board document:
|
||||||
cargo run --bin kicad-ipc-cli -- text-variables
|
cargo run --bin kicad-ipc-cli -- text-variables
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Set text variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run --bin kicad-ipc-cli -- set-text-variables --merge-mode merge --var REV=A
|
||||||
|
```
|
||||||
|
|
||||||
Expand text variables in one or more input strings:
|
Expand text variables in one or more input strings:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ const CMD_GET_PLUGIN_SETTINGS_PATH: &str = "kiapi.common.commands.GetPluginSetti
|
||||||
const CMD_GET_NET_CLASSES: &str = "kiapi.common.commands.GetNetClasses";
|
const CMD_GET_NET_CLASSES: &str = "kiapi.common.commands.GetNetClasses";
|
||||||
const CMD_SET_NET_CLASSES: &str = "kiapi.common.commands.SetNetClasses";
|
const CMD_SET_NET_CLASSES: &str = "kiapi.common.commands.SetNetClasses";
|
||||||
const CMD_GET_TEXT_VARIABLES: &str = "kiapi.common.commands.GetTextVariables";
|
const CMD_GET_TEXT_VARIABLES: &str = "kiapi.common.commands.GetTextVariables";
|
||||||
|
const CMD_SET_TEXT_VARIABLES: &str = "kiapi.common.commands.SetTextVariables";
|
||||||
const CMD_EXPAND_TEXT_VARIABLES: &str = "kiapi.common.commands.ExpandTextVariables";
|
const CMD_EXPAND_TEXT_VARIABLES: &str = "kiapi.common.commands.ExpandTextVariables";
|
||||||
const CMD_GET_TEXT_EXTENTS: &str = "kiapi.common.commands.GetTextExtents";
|
const CMD_GET_TEXT_EXTENTS: &str = "kiapi.common.commands.GetTextExtents";
|
||||||
const CMD_GET_TEXT_AS_SHAPES: &str = "kiapi.common.commands.GetTextAsShapes";
|
const CMD_GET_TEXT_AS_SHAPES: &str = "kiapi.common.commands.GetTextAsShapes";
|
||||||
|
|
@ -509,6 +510,33 @@ impl KiCadClient {
|
||||||
Ok(response.variables.into_iter().collect())
|
Ok(response.variables.into_iter().collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn set_text_variables_raw(
|
||||||
|
&self,
|
||||||
|
variables: BTreeMap<String, String>,
|
||||||
|
merge_mode: MapMergeMode,
|
||||||
|
) -> Result<prost_types::Any, KiCadError> {
|
||||||
|
let command = common_commands::SetTextVariables {
|
||||||
|
document: Some(self.current_board_document_proto().await?),
|
||||||
|
variables: Some(common_project::TextVariables {
|
||||||
|
variables: variables.into_iter().collect(),
|
||||||
|
}),
|
||||||
|
merge_mode: map_merge_mode_to_proto(merge_mode),
|
||||||
|
};
|
||||||
|
let response = self
|
||||||
|
.send_command(envelope::pack_any(&command, CMD_SET_TEXT_VARIABLES))
|
||||||
|
.await?;
|
||||||
|
response_payload_as_any(response, RES_PROTOBUF_EMPTY)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn set_text_variables(
|
||||||
|
&self,
|
||||||
|
variables: BTreeMap<String, String>,
|
||||||
|
merge_mode: MapMergeMode,
|
||||||
|
) -> Result<BTreeMap<String, String>, KiCadError> {
|
||||||
|
let _ = self.set_text_variables_raw(variables, merge_mode).await?;
|
||||||
|
self.get_text_variables().await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn expand_text_variables_raw(
|
pub async fn expand_text_variables_raw(
|
||||||
&self,
|
&self,
|
||||||
text: Vec<String>,
|
text: Vec<String>,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue