From 9f48ddfd735d218ea91537dfc98dcbbe6c996ea2 Mon Sep 17 00:00:00 2001 From: Scott Claiborne Date: Wed, 29 Apr 2026 12:51:26 -0700 Subject: [PATCH 1/2] Support AS6 install paths AS6 installs to 'C:\Program Files (x86)\BRAutomation' instead of the legacy 'C:\BrAutomation'. getASPath() now probes a list of candidate base directories and prefers the one containing the requested AS version folder, falling back to the legacy default. Preserves behavior for AS<=4.x. --- ASTools.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/ASTools.py b/ASTools.py index a3aff59..6865bc9 100644 --- a/ASTools.py +++ b/ASTools.py @@ -69,8 +69,33 @@ 28341: 'Transfer to the corresponding target system is not possible since the AR version on the target system does not yet support the transfer mode' } +# Candidate base directories where B&R Automation Studio may be installed. +# AS <= 4.x defaults to C:\BrAutomation. AS 6 changed the default to +# C:\Program Files (x86)\BRAutomation (note: no space in "BRAutomation"). +_AS_BASE_CANDIDATES = [ + "C:\\BrAutomation", + "C:\\Program Files (x86)\\BRAutomation", + "C:\\Program Files\\BRAutomation", +] + +def _findASBase(version:str='') -> str: + """Return the base BrAutomation directory. + + If a specific version is provided, prefer a base that actually contains + a folder for that version. Otherwise return the first base that exists. + Falls back to the legacy default 'C:\\BrAutomation' if none are found. + """ + if version and version.lower() != 'base': + for base in _AS_BASE_CANDIDATES: + if os.path.isdir(os.path.join(base, version.upper())): + return base + for base in _AS_BASE_CANDIDATES: + if os.path.isdir(base): + return base + return _AS_BASE_CANDIDATES[0] + def getASPath(version:str) -> str: - base = "C:\\BrAutomation" + base = _findASBase(version) if version.lower() == 'base': return base else: From 4238149af0dfc0660ef7467196657e2e6e70d3f5 Mon Sep 17 00:00:00 2001 From: Scott Claiborne Date: Thu, 30 Apr 2026 12:40:33 -0700 Subject: [PATCH 2/2] Use major-only folder name for AS 6.x AS <= 4.x installs to versioned folders like AS41/AS45/AS46 (major+minor). AS 6.x installs into a single AS6 folder where minor revisions (6.0, 6.1, 6.5, ...) share one install path. _parseASVersion now emits AS when major >= 6 so getASBuildPath/getASPath resolve correctly for AS6 projects (e.g. an apj declaring Version="6.5.1.7" now maps to AS6 instead of the non-existent AS65). --- ASTools.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ASTools.py b/ASTools.py index 6865bc9..6b3735c 100644 --- a/ASTools.py +++ b/ASTools.py @@ -923,7 +923,17 @@ def ASVersion(self) -> str: @staticmethod def _parseASVersion(apj:str) -> str: result = re.search('= 6: + version = result[0] + else: + version = ''.join(result[0:2]) return 'AS' + version def getHardwareParameter(self, config, paramName) -> str: