Toolbox¶
| CLASS | DESCRIPTION |
|---|---|
Done |
An Empty Output parameter that can be used to signal that a tool has completed in Model Builder |
Double |
Simple Double/Float parameter with default and filter passthroughs |
FeatureDataset |
Simple Feature Dataset parameter with filter and default passthroughs |
FeatureLayer |
Simple Feature Layer parameter with filter and default passthroughs |
FeatureLayerList |
Simple Feature Layer parameter with filter and default passthroughs |
FilePath |
Simple filepath input with default and filter passthroughs |
Folder |
Simple Feature Layer parameter with filter and default passthroughs |
HiddenString |
Simple string input parameter with filter options and default passthrough |
Integer |
Simple Integer number parameter with default and filter passthroughs |
MultiFilePath |
Simple milti-filepath input with default and filter passthroughs |
Parameters |
Wrap a list of parameters and override the index to allow indexing by name |
String |
Simple string input parameter with filter options and default passthrough |
StringList |
Simple string list with default and filter passthroughs |
TextBox |
Simple multiline text box parameter with filter options and default passthrough |
Toggle |
Simple toggle button with a name and default state |
Tool |
|
ValueTable |
Simple ValueTable parameter with filter and default passthroughs |
| FUNCTION | DESCRIPTION |
|---|---|
safe_load |
Safely load in tools to a toolbox placing all failed imports in a |
toolify |
Convert a typed function into a tool for the specified Toolbox class |
Done
¶
Done()
Bases: Parameter
An Empty Output parameter that can be used to signal that a tool has completed in Model Builder
Source code in src/arcpie/toolbox.py
108 109 110 111 112 113 114 115 | |
Double
¶
Double(
displayName: str,
options: list[float] | None = None,
default: float | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple Double/Float parameter with default and filter passthroughs
Source code in src/arcpie/toolbox.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
FeatureDataset
¶
FeatureDataset(
displayName: str,
options: list[str] | None = None,
default: str | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple Feature Dataset parameter with filter and default passthroughs
Source code in src/arcpie/toolbox.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | |
FeatureLayer
¶
FeatureLayer(
displayName: str,
options: list[str] | None = None,
default: str | None = None,
required: bool = True,
name: str | None = None,
allow_create: bool = False,
category: str | None = None,
)
Bases: Parameter
Simple Feature Layer parameter with filter and default passthroughs
Source code in src/arcpie/toolbox.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
FeatureLayerList
¶
FeatureLayerList(
displayName: str,
options: list[str] | None = None,
default: str | None = None,
required: bool = True,
name: str | None = None,
allow_create: bool = False,
category: str | None = None,
)
Bases: Parameter
Simple Feature Layer parameter with filter and default passthroughs
Source code in src/arcpie/toolbox.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
FilePath
¶
FilePath(
displayName: str,
options: list[str] | None = None,
default: str | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple filepath input with default and filter passthroughs
Source code in src/arcpie/toolbox.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
Folder
¶
Folder(
displayName: str,
options: list[str] | None = None,
default: str | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple Feature Layer parameter with filter and default passthroughs
Source code in src/arcpie/toolbox.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
HiddenString
¶
HiddenString(
displayName: str,
options: list[str] | None = None,
default: str | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple string input parameter with filter options and default passthrough
Source code in src/arcpie/toolbox.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
Integer
¶
Integer(
displayName: str,
options: list[int] | range | None = None,
default: int | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple Integer number parameter with default and filter passthroughs
Source code in src/arcpie/toolbox.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
MultiFilePath
¶
MultiFilePath(
displayName: str,
options: list[str] | None = None,
default: str | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple milti-filepath input with default and filter passthroughs
Source code in src/arcpie/toolbox.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
Parameters
¶
String
¶
String(
displayName: str,
options: list[str] | None = None,
default: str | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple string input parameter with filter options and default passthrough
Source code in src/arcpie/toolbox.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
StringList
¶
StringList(
displayName: str,
options: list[str] | None = None,
defaults: list[str] | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple string list with default and filter passthroughs
Source code in src/arcpie/toolbox.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
TextBox
¶
TextBox(
displayName: str,
options: list[str] | None = None,
default: str | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: String
Simple multiline text box parameter with filter options and default passthrough
Source code in src/arcpie/toolbox.py
165 166 167 168 169 170 171 172 | |
Toggle
¶
Toggle(
displayName: str,
default: bool = False,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple toggle button with a name and default state
Source code in src/arcpie/toolbox.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
Tool
¶
Tool()
Bases: ToolABC
| ATTRIBUTE | DESCRIPTION |
|---|---|
project |
Get the current project that the tool is running in if it exists (otherwise: None)
TYPE:
|
Source code in src/arcpie/toolbox.py
40 41 42 43 | |
ValueTable
¶
ValueTable(
displayName: str,
columns: dict[str, ParameterDatatype],
filters: dict[str, list[Any]] | None = None,
defaults: list[dict[str, str]] | None = None,
required: bool = True,
name: str | None = None,
category: str | None = None,
)
Bases: Parameter
Simple ValueTable parameter with filter and default passthroughs
Source code in src/arcpie/toolbox.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
safe_load
¶
safe_load(
tools: dict[str, list[str]],
*,
scope: dict[str, Any] | None = None,
reload_module: bool = False,
) -> list[type[ToolABC]]
Safely load in tools to a toolbox placing all failed imports in a Broken Tools category
| PARAMETER | DESCRIPTION |
|---|---|
|
A mapping of tool modules to tool files or tool classes in a module |
|
The |
|
Reload the module after importing (default: False)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[type[ToolABC]]
|
A list of tool classes |
Note
To isolate bugs in a large toolbox, it is reccomended that you use file/module level importing
with matching toolclass names (e.g. Tool.py -> class Tool) where the Tool mapping is:
Tools = {'tools': ['Tool.py']}
instead of:
Tools = {'tools.Tool': ['Tool']}
This allows the import to fail softly on a single tool instead of breaking imports for all other
toolclasses in that Tool.py module.
Any tools with errors will be placed in a Broken Tools category in the toolbox with the full
stack trace placed in its description field. The final component of the exception will be placed
at the end of the tool label for easy debugging.
Example
>>> # File import
>>> Tools = {
... # import matching class from named file in a submodule (tools)
... # where ToolFileA is ToolFileA.py with a class ToolFileA
... 'tools': ['ToolFileA', 'ToolFileB'],
...
... # Import explicit ToolClass from toolfile (MyTools.py)
... # NOT RECOMMENDED
... 'tools.MyTools': ['ToolClassA', 'ToolClassB'],
... }
>>> tools = safe_import(globals(), Tools)
Source code in src/arcpie/toolbox.py
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 | |
toolify
¶
toolify(
*tool_registries: list[type[ToolABC]],
name: str | None = None,
params: ParameterTypeMap | None = None,
debug: bool = False,
logger: Logger | None = None,
)
Convert a typed function into a tool for the specified Toolbox class
| PARAMETER | DESCRIPTION |
|---|---|
|
The tool registry lists to add this tool to |
|
The name of the tool
TYPE:
|
|
A mapping of parameter names to Parameter types and a callable constructor that converts the parameter to the expected value for the function parameter. You can also pass a fully formed arcpy.Parameter object as the first item in the tuple instead of a simple type
TYPE:
|
|
Print the converted arguments to the ArcGIS Pro message console (default: False)
TYPE:
|
|
An optional logger to use for logging all runs of the toolified tool
TYPE:
|
Usage
>>> @toolify(
>>> TOOL_REGISTRY,
>>> name='PDF Exporter',
>>> params={
>>> 'project': ('DEFile', lambda p: Project(p.valueAsText)),
>>> 'outfile': ('DEFile', lambda p: Path(p.valueAsText))
>>> }
>>> )
>>> def export_pdf(project: Project|str='CURRENT', outfile: Path|str='out.pdf') -> None:
>>> ...
Source code in src/arcpie/toolbox.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | |