def store_command(self, function, parameters): """Stores a valid pyansys function with parameters""" parsed_parameters = [] for parameter in parameters: parameter = parameter.strip() if is_float(parameter): parsed_parameters.append(parameter) elif "ARG" in parameter and self._infunction: parsed_parameters.append("%s" % parameter) else: parsed_parameters.append('"%s"' % parameter) parameter_str = ", ".join(parsed_parameters) if self.comment: line = "%s%s.%s(%s) # %s" % ( self.indent, self.obj_name, function, parameter_str, self.comment, ) else: line = "%s%s.%s(%s)" % (self.indent, self.obj_name, function, parameter_str) self.lines.append(line)
def _get_available_base_ansys(): """Return a dictionary of available ANSYS versions with their base paths. Returns ------- Return all installed ANSYS paths in Windows >>> _get_available_base_ansys() {194: 'C:\\Program Files\\ANSYS INC\\v194', 202: 'C:\\Program Files\\ANSYS INC\\v202', 211: 'C:\\Program Files\\ANSYS INC\\v211'} Within Linux >>> _get_available_base_ansys() {194: '/usr/ansys_inc/v194', 202: '/usr/ansys_inc/v202', 211: '/usr/ansys_inc/v211'} """ base_path = None if os.name == 'nt': supported_versions = [194, 202, 211, 212, 221] awp_roots = { ver: os.environ.get(f'AWP_ROOT{ver}', '') for ver in supported_versions } installed_versions = { ver: path for ver, path in awp_roots.items() if path and os.path.isdir(path) } if installed_versions: return installed_versions else: base_path = os.path.join(os.environ['PROGRAMFILES'], 'ANSYS INC') elif os.name == 'posix': for path in ['/usr/ansys_inc', '/ansys_inc']: if os.path.isdir(path): base_path = path else: raise OSError(f'Unsupported OS {os.name}') if base_path is None: return {} paths = glob(os.path.join(base_path, 'v*')) if not paths: return {} ansys_paths = {} for path in paths: ver_str = path[-3:] if is_float(ver_str): ansys_paths[int(ver_str)] = path return ansys_paths