Loading...
Loading...
Reference for Siemens TIA Scripting Python V1.4.3. Load only when the user explicitly chooses Python TIA Scripting or the TIA roadmap routes to it.
npx skill4agent add czarnak/totally-integrated-claude tia-pythonsiemens_tia_scriptingtia-openness-roadmap109742322_TIA_Scripting_Python_DOC_V143_en.pdfsiemens_tia_scripting.pyimanifest.jsonSiemens TIA Opennesspy -3.12 -m pip install .\install\siemens_tia_scripting-1.4.3-cp312-cp312-win_amd64.whl
py -3.13 -m pip install .\install\siemens_tia_scripting-1.4.3-cp313-cp313-win_amd64.whl
py -3.14 -m pip install .\install\siemens_tia_scripting-1.4.3-cp314-cp314-win_amd64.whlTIA_SCRIPTINGsiemens_tia_scripting.pydimport importlib
import os
import sys
from pathlib import Path
try:
ts = importlib.import_module("siemens_tia_scripting")
except ImportError as first_error:
scripting_dir = os.environ.get("TIA_SCRIPTING")
if not scripting_dir:
raise RuntimeError(
"Install the matching Siemens wheel or set TIA_SCRIPTING."
) from first_error
resolved_dir = Path(scripting_dir).expanduser().resolve()
if not (resolved_dir / "siemens_tia_scripting.pyd").is_file():
raise RuntimeError(
"TIA_SCRIPTING must contain siemens_tia_scripting.pyd."
) from first_error
sys.path.insert(0, str(resolved_dir))
ts = importlib.import_module("siemens_tia_scripting")siemens_tia_scripting
|-- Enums and 10 global functions
|-- ProductBundle -> Product
`-- Portal
|-- Project
| |-- Device -> Module
| |-- Plc
| | |-- DownloadConfig
| | |-- ExecutionResult
| | |-- ProgramBlock / SystemBlock / UserDataType
| | |-- PlcTagTable -> PlcTag / UserConstant / SystemConstant
| | |-- ExternalSource / ForceTable / WatchTable
| | |-- TechnologyObject / SafetyAdministration
| | `-- SoftwareUnit -> NamedValueType and PLC data objects
| |-- Hmi
| | |-- HmiTagTable / HmiTag / HmiScreen / HmiScript
| | `-- HmiAlarm / HmiAlarmClass / HmiConnection / HmiCycle
| | / HmiGraphicList / HmiTextList
| |-- ProjectLibrary -> MasterCopy / LibraryType -> LibraryTypeVersion
| `-- ApplicationTest / RuleSet / SystemTest
|-- ProjectServer
`-- GlobalLibraryInfo / GlobalLibrary
`-- LibraryType -> LibraryTypeVersionget_property(name: str) -> strvalue = obj.get_property(name="CreationDate")
if isinstance(value, bool):
normalized = value
elif isinstance(value, str):
normalized = value.strip()
else:
normalized = valueset_property(name: str, value: str) -> intobj.export(
target_directory_path=r"C:\Engineering\export",
export_options=ts.Enums.GeneralExportOptions.WithDefaults,
export_format=ts.Enums.GeneralExportFormats.SimaticML,
keep_folder_structure=True,
)import_options: Optional[Enums.GeneralImportOptions]Device.compile()Module.compile()SoftwareUnit.compile()ExecutionResultExecutionResultget_result_state()get_all_messages()get_warnings()get_errors()get_information()print_result()Hmi.compile_hardware()Hmi.compile_software()TrueFalseExecutionResultExecutionResultresult = plc.compile_software()
errors = result.get_errors()
if errors:
raise RuntimeError("PLC compile failed: " + " | ".join(errors))PortalMode: WithGraphicalUserInterface=0, WithoutGraphicalUserInterface=1,
AnyUserInterface=2
UmacUserMode: Project=0, Global=1
GeneralExportFormats: SimaticML=0, ExternalSource=1, SimaticSD=2
GeneralExportOptions: WithDefaults=0, Nan=1, WithReadOnly=2
LibraryCleanUpMode: PreserveDefaultVersionOfUnusedTypes=0, DeleteUnusedTypes=1
LibraryExportOptions: Nan=0, WithLibraryVersionInfoFile=1,
OnlyLibraryVersionInfoFile=2
LibraryHarmonizeOptions: HarmonizePathsAndNames=0, HarmonizePaths=1,
HarmonizeNames=2
LibraryDependenciesMode: DoNotAutomaticallyCreateOrReleaseDependencies=0,
AutomaticallyCreateOrReleaseDependenciesIfRequired=1
GeneralDownloadOptions: Hardware=0, Software=1, HardwareAndSoftware=2,
SoftwareOnlyChanges=3,
HardwareAndSoftwareOnlyChanges=4
TestSuiteTestCaseImportOptions: Nan=0, IgnoreInvalidObject=1
TestSuiteRuleSetImportOptions: Nan=0, IgnorePropertyErrors=1,
IgnoreMissingAttributes=2, SkipInvalidObjects=3,
IgnoreErrorsAndAttributes=4
GeneralImportOptions: Nan=0, Override=1, SkipInactiveCultures=2,
ActivateInactiveCultures=3
ConsoleLogLevel: All=0, Info=1, Warning=2, Error=3ts.set_logging(path=r"C:\Engineering\logs\tia-scripting.log", console=True)
ts.set_log_level(log_level=ts.Enums.ConsoleLogLevel.Info)| Reference | Load for |
|---|---|
| Global functions, portal lifecycle, credentials, products, devices, and modules |
| PLC online/download, compilation, imports/exports, CFC, Safety, software units, and PLC data objects |
| Generic wrapper HMI discovery, compile, import/export, and HMI object classes |
| Global/project libraries, master copies, types, and versions |
| Project lifecycle, transactions, project texts, CAx, project servers, and Test Suite |
delete()go_online()go_offline()download()pc_interface_typepc_interface_nametarget_interfaceExecutionResultTruecompile_checkproject.start_transaction()project.end_transaction()transaction_open = False
try:
project.start_transaction(
undo_text="Authorized TIA change",
dialog_text="Applying reviewed Python changes",
)
transaction_open = True
# Perform only the already authorized mutation here.
project.end_transaction(rollback=False)
transaction_open = False
except Exception:
if transaction_open:
project.end_transaction(rollback=True)
raiseportal.detach()portal.close_portal()folder_pathplcs[0]