"""ACCS scripting module
This module allows to integrate ACCS into WB scripting.
It supports WB Project and WB Mechanical.
.. code-block:: python
:linenos:
import ACCS_scripting
print(dir(ACCS_scripting))
ACCS_proj = ACCS_scripting.Project()
print(ACCS_proj.CheckMaterial())
"""
import os
try:
import clr as _clr
import Ansys as _Ansys
_clr.AddReference("Ansys.ACT.Core")
except Exception:
pass
"""
import sys
sys.path.insert(0,r'D:\cedric\CST_ANSYS\0_stable\ACT\scripting')
if 'ACCS_scripting' in sys.modules:
del sys.modules['ACCS_scripting']
gls = globals()
for g in [g for g in gls if 'ACCS_' in g]:
del(globals()[g])
"""
class _Meta:
def __init__(self, API):
self.ExtAPI = API
self.ACCS_ext = self.ExtAPI.ExtensionManager.GetExtensionByName("ACCS")
if self.ACCS_ext is None:
raise RuntimeError("The ACCS extension does not seem to be loaded")
self.ACCS_mod = self.ACCS_ext.GetModule()
def _hideMessageBox(self, state):
"""Hides or shows the message boxes.
:param state: The Message boxes will be hidden if True
:type state: bool
"""
if state not in [True, False]:
raise RuntimeError("The supplied argument must be a boolean.")
self.ACCS_mod.csts.IsInteractive = not state
def _isMechanical(self):
"""determines if it is being run from mechanical."""
return _Ansys.ACT.Core.ApplicationRepository.GetApplication("Project") is None
def VersionStringDotted(self):
"""Returns the ACCS Version String with dots."""
return self.ACCS_mod.GetACCSVersDot()
def VersionString(self):
"""Returns the ACCS Version String without dots."""
return self.ACCS_mod.GetACCSVers()
def VersionStringDottedFull(self):
"""Returns the ACCS Version String with dots and hotfix."""
return self.ACCS_mod.GetACCSVersDotFull()
[docs]
class Project(_Meta):
"""Project class
Class to use to script ACCS from Workbench
.. note::
It is important to create the instance after loading the project
"""
def __init__(self):
if self._isMechanical():
raise RuntimeError("This can only be used within a Project script.")
try:
import Extensions as _Extensions
except Exception:
pass
try:
_Extensions.LoadExtension(
Id="90932E6A-9319-4952-B00B-3B2857BEA465", Format="Binary"
)
except Exception:
try:
_Extensions.LoadExtension(
Id="90932E6A-9319-4952-B00B-3B2857BEA465", Format="Scripted"
)
except Exception:
pass
APP = _Ansys.ACT.Core.ApplicationRepository.GetApplication("Project")
_Meta.__init__(self, APP.GetExtensionApi(None))
[docs]
def CheckMaterial(self):
"""Checks all materials in the project to see if they have not been imported from an earlier release."""
self._hideMessageBox(True)
ret = self.ACCS_mod.CheckMaterial()
self._hideMessageBox(False)
return ret
[docs]
def UpgradeMaterial(self):
"""Upgrades all materials that were imported from an earlier release."""
self._hideMessageBox(True)
self.ACCS_mod.ACCS_Proj_Upgrade(None)
self._hideMessageBox(False)
[docs]
def HomogeneizeMaterial(self):
"""Adds homogeneized properties for all materials which were defined via the fibre/matrix formulation."""
self._hideMessageBox(True)
self.ACCS_mod.ACCS_Proj_FM(None)
self._hideMessageBox(False)
def CreateRTMSystem(self, GetAllVisibleTemplates, Position, RelativeTo):
ACCSRTM_tpl = [p for p in GetAllVisibleTemplates() if p.Name == "RTMSolver"][0]
ACCSRTM_sys = ACCSRTM_tpl.CreateSystem(Position=Position, RelativeTo=RelativeTo)
return ACCSRTM_sys
[docs]
class Mechanical(_Meta):
"""Mechanical class
Class to use to script ACCS from Mechanical
"""
def __init__(self, API):
if not self._isMechanical():
raise RuntimeError("This can only be used within a Mechanical script.")
_Meta.__init__(self, API)
[docs]
def AddACCS(self, analysis):
"""Adds the ACCS module to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
load = self.ACCS_mod.ACCS_Mech_AddLd(analysis)
if load is None:
load = [o for o in analysis.GetLoadObjects("ACCS") if o.Name == "ACCS_Ld"][
0
]
self._hideMessageBox(False)
return ACCSload(
load,
self.ExtAPI.DataModel.GetObjectById(load.ObjectId),
)
[docs]
def AddSupportRemover(self, analysis):
"""Adds the ACCS module to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
load = self.ACCS_mod.ACCS_Mech_AddSupRem(analysis)
self._hideMessageBox(False)
return ACCSsuprem(
load,
self.ExtAPI.DataModel.GetObjectById(load.ObjectId),
)
[docs]
def AddSurfaceExporter(self, analysis):
"""Adds the ACCS Surface Exporter module to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddExpSurf(analysis)
self._hideMessageBox(False)
return ACCSsurexp(
res,
self.ExtAPI.DataModel.GetObjectById(res.ObjectId),
)
[docs]
def AddInistateImporter(self, analysis):
"""Adds the ACCS Inistate Importer module to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddIniSta(analysis)
self._hideMessageBox(False)
return ACCSinistate(
res,
self.ExtAPI.DataModel.GetObjectById(res.ObjectId),
)
[docs]
def AddRTMThermalImport(self, analysis):
"""Adds the ACCS RTM Thermal Import Load to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
load = self.ACCS_mod.RTM_createThermalImport(analysis)
self._hideMessageBox(False)
return RTM_Thermal_Import(
load,
self.ExtAPI.DataModel.GetObjectById(load.ObjectId),
)
[docs]
def AddRTMResultImport(self, analysis):
"""Adds the ACCS RTM Result Import Load to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
load = self.ACCS_mod.RTM_createResultImport(analysis)
self._hideMessageBox(False)
return RTM_Result_Import(
load,
self.ExtAPI.DataModel.GetObjectById(load.ObjectId),
)
[docs]
def AddRTMFlowRateInlet(self, analysis):
"""Adds the ACCS RTM Flow Rate Inlet Load to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
load = self.ACCS_mod.RTM_createFlowRateInlet(analysis)
self._hideMessageBox(False)
return RTMInletLoad(
load,
self.ExtAPI.DataModel.GetObjectById(load.ObjectId),
)
[docs]
def AddRTMPressureInlet(self, analysis):
"""Adds the ACCS RTM Pressure Inlet Load to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
load = self.ACCS_mod.RTM_createPressureInlet(analysis)
self._hideMessageBox(False)
return RTMInletLoad(
load,
self.ExtAPI.DataModel.GetObjectById(load.ObjectId),
)
[docs]
def AddRTMOutlet(self, analysis):
"""Adds the ACCS RTM Pressure Inlet Load to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
load = self.ACCS_mod.RTM_createOutlet(analysis)
self._hideMessageBox(False)
return RTMOutletLoad(
load,
self.ExtAPI.DataModel.GetObjectById(load.ObjectId),
)
[docs]
def AddRTMResultExport(self, analysis):
"""Adds the RTM Result Export result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_addExport(analysis)
self._hideMessageBox(False)
return RTM_Result_Export(
res,
self.ExtAPI.DataModel.GetObjectById(res.ObjectId),
)
[docs]
def AddRTMResultFill(self, analysis):
"""Adds the RTM Fill result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createFill(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultBC(self, analysis):
"""Adds the RTM BC result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createBC(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultDegreeOfCure(self, analysis):
"""Adds the RTM Degree Of Cure result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createDegreeOfCure(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultEntrapment(self, analysis):
"""Adds the RTM Entrapment result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createEntrapment(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultFlowRate(self, analysis):
"""Adds the RTM Flow Rate result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createFlowRate(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultGateOpenTime(self, analysis):
"""Adds the RTM Gate Open Time result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createGateOpenTime(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultInfusionTime(self, analysis):
"""Adds the RTM Infusion Time result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createInfusionTime(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultPressure(self, analysis):
"""Adds the RTM Pressure result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createPressure(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultTempBC(self, analysis):
"""Adds the RTM Temp BC result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createTempBC(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultTemperature(self, analysis):
"""Adds the RTM Temperature result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createTemperature(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultViscosity(self, analysis):
"""Adds the RTM Viscosity result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createViscosity(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultVelocity(self, analysis):
"""Adds the RTM Velocity result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createVelocity(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultVelocityX(self, analysis):
"""Adds the RTM Velocity X result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createVelocityX(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultVelocityY(self, analysis):
"""Adds the RTM Velocity Y result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createVelocityY(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultVelocityZ(self, analysis):
"""Adds the RTM Velocity Z result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createVelocityZ(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultTG(self, analysis):
"""Adds the RTM TG result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createTG(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultResinState(self, analysis):
"""Adds the RTM Resin State result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createResinState(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultdV_Cure(self, analysis):
"""Adds the RTM Cure Shrinkage result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createdV_Cure(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultdV_Thermal(self, analysis):
"""Adds the RTM Thermal Expansion result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createdV_Thermal(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddRTMResultdV_Total(self, analysis):
"""Adds the RTM Total Volume Change result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.RTM_createdV_Total(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultState(self, analysis):
"""Adds the ACCS Material State result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResState(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultAlpha(self, analysis):
"""Adds the ACCS Degree of Cure/Crystallisation result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResAlpha(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultTg(self, analysis):
"""Adds the ACCS Glass transition temperature/reference result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResTg(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultHeat(self, analysis):
"""Adds the ACCS Generated Heat result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResQdot(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultEpsShXX(self, analysis):
"""Adds the ACCS Cure Shrinkage XX result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResExtraEpsShXX(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultEpsShYY(self, analysis):
"""Adds the ACCS Cure Shrinkage YY result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResExtraEpsShYY(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultEpsShZZ(self, analysis):
"""Adds the ACCS Cure Shrinkage ZZ result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResExtraEpsShZZ(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultEpsElXX(self, analysis):
"""Adds the elastic strain XX result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResExtraEpsElXX(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultEpsElYY(self, analysis):
"""Adds the elastic strain YY result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResExtraEpsElYY(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultEpsElZZ(self, analysis):
"""Adds the elastic strain ZZ result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResExtraEpsElZZ(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultEpsElXY(self, analysis):
"""Adds the elastic strain XY result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResExtraEpsElXY(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultEpsElYZ(self, analysis):
"""Adds the elastic strain YZ result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResExtraEpsElYZ(analysis)
self._hideMessageBox(False)
return res
[docs]
def AddResultEpsElXZ(self, analysis):
"""Adds the elastic strain XZ result to the input analysis.
:param analysis: The analysis to which it should be added
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(analysis, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied argument must be an analysis.")
self._hideMessageBox(True)
res = self.ACCS_mod.ACCS_Mech_AddResExtraEpsElXZ(analysis)
self._hideMessageBox(False)
return res
[docs]
def CopyAnalysisSettings(self, AnalysisFrom, AnalysisTo):
"""Copies analysis settings between two simulations.
:param AnalysisFrom: The source analysis
:type AnalysisFrom: Ansys.ACT.Automation.Mechanical.Analysis
:param AnalysisTo: The destination analysis
:type AnalysisTo: Ansys.ACT.Automation.Mechanical.Analysis
"""
if not isinstance(
AnalysisFrom, _Ansys.ACT.Automation.Mechanical.Analysis
) or not isinstance(AnalysisTo, _Ansys.ACT.Automation.Mechanical.Analysis):
raise RuntimeError("The supplied arguments must be analyses.")
self._hideMessageBox(True)
self.ACCS_mod.CopyAS(AnalysisFrom, AnalysisTo)
self._hideMessageBox(False)
[docs]
def changeRTMSolverSetting(
self, analysis, property_name=None, property_value=None, result_only=False
):
"""Copies analysis settings between two simulations.
:param analysis: The source analysis
:type analysis: Ansys.ACT.Automation.Mechanical.Analysis
:param property_name: Name of the solver property that is to be changed.
:type property_name: String
:param property_value: The new value of the selected solver property.
:type property_value: String
:param result_only: Defines if the solver is result only.
:type result_only: Boolean
"""
solver = analysis.Solver
if result_only:
solver.Properties["ResultOnly"].ValueString = "True"
elif (
(not result_only)
and (property_name is not None)
and (property_value is not None)
):
solver.Properties["ResultOnly"].ValueString = "False"
solver.Properties["ResultOnly/" + property_name].Value = property_value
else:
raise RuntimeError(
"If result only is false, a property value and property name must be defined."
)
solver.NotifyChange()
class _ACCSObj:
def __init__(self, uObj, tObj):
self.uObj = uObj
self.tObj = tObj
def set_property(self, prop_name, prop_value):
self.uObj.Properties[prop_name].Value = prop_value
self.uObj.NotifyChange()
def suppress(self):
self.uObj.Suppressed = True
def unsuppress(self):
self.uObj.Suppressed = False
def getname(self):
return self.tObj.Name
def setname(self, name):
self.tObj.Name = name
class _ACCSFilePathObj(_ACCSObj):
"""ACCS File Path Load
Base class for all loads with filepath properties
"""
def __init__(self, uObj, tObj):
_ACCSObj.__init__(self, uObj, tObj)
def path_exist(self, filepath):
if filepath is None:
raise RuntimeError("Filepath not found or is None")
elif os.path.exists(filepath):
return True
else:
return False
[docs]
class ACCSload(_ACCSObj):
"""ACCS load class
Class to use to script the ACCS load from Mechanical
"""
def __init__(self, uObj, tObj):
_ACCSObj.__init__(self, uObj, tObj)
[docs]
def setAnalysisType(self, t):
"""Sets the ACCS Analysis Type.
:param t: The analysis type either 'Full' or 'Fast'
:type t: str
"""
if self.uObj.Analysis.PhysicsType == "Thermal":
raise RuntimeError(
"The ACCS analysis type can only be set for a Mechanical analysis."
)
if t not in self.uObj.Properties["ACCS_Ld_SelectType"].Options:
raise RuntimeError(
"The analysis type must be among these valid options: "
+ str(self.uObj.Properties["ACCS_Ld_SelectType"].Options)
)
self.set_property("ACCS_Ld_SelectType", t)
[docs]
def setMRCC(self, steps):
"""Sets the ACCS Cure cycle for the mechanical FAST approach.
:param MRCC: The cure cycle shall be defined with a list of steps. A step can be defined as a Heating/Cooling step with ['Heating Rate', X, Y] defines a Heating/Cooling step at a rate of X C/min until reaching Y C or ['Fixed temperature', Z]: defines a Fixed temperature step with a duration of Z minutes.
:type MRCC: list[step]
"""
if self.uObj.Analysis.PhysicsType == "Thermal":
raise RuntimeError(
"The ACCS Cure Cycle can only be defined for a Mechanical analysis."
)
SelectType = self.uObj.Properties["ACCS_Ld_SelectType"]
if SelectType.Value != "Fast":
raise RuntimeError(
"The ACCS Cure Cycle can only be defined for a ACCS FAST approach."
)
Tprof_type = SelectType.Properties.GetByName("ACCS_Ld_fast_Tprof_type")
Tprof_type.Value = "MRCC"
self.uObj.NotifyChange()
MRCC = Tprof_type.Properties.GetByName("ACCS_Ld_fast_Tprof_MRCC")
MRCC_Type = MRCC.Properties.GetByName("ACCS_Ld_fast_Tprof_MRCC_Type")
HeatingRate = MRCC_Type.Properties.GetByName(
"ACCS_Ld_fast_Tprof_MRCC_HeatingRate"
)
Temperature = MRCC_Type.Properties.GetByName(
"ACCS_Ld_fast_Tprof_MRCC_Temperature"
)
Time = MRCC_Type.Properties.GetByName("ACCS_Ld_fast_Tprof_MRCC_Time")
while 0 < MRCC.RowCount:
MRCC.DeleteRow(0)
for s in steps:
MRCC.AddRow()
if s[0].lower() == "heating rate":
MRCC_Type.Value = "Heating Rate"
HeatingRate.Value = s[1]
Temperature.Value = s[2]
elif s[0].lower() == "fixed temperature":
MRCC_Type.Value = "Fixed temperature"
Time.Value = s[1]
else:
raise RuntimeError(
"The step type must be among these valid options: "
+ str(MRCC_Type.Options)
)
Time.Validate()
MRCC.SaveActiveRow()
MRCC.Validate()
[docs]
def setTvst(self, Tprof):
"""Sets the ACCS Cure cycle for the mechanical FAST approach.
:param Tprof: The cure cycle shall be defined with a list of points. [10, 120] defines a point at 10 seconds and 120 C
:type Tprof: list[point]
"""
if self.uObj.Analysis.PhysicsType == "Thermal":
raise RuntimeError(
"The ACCS Cure Cycle can only be defined for a Mechanical analysis."
)
SelectType = self.uObj.Properties["ACCS_Ld_SelectType"]
if SelectType.Value != "Fast":
raise RuntimeError(
"The ACCS Cure Cycle can only be defined for a ACCS FAST approach."
)
Tprof_type = SelectType.Properties.GetByName("ACCS_Ld_fast_Tprof_type")
Tprof_type.Value = "Temperature-time"
self.uObj.NotifyChange()
Tvst = Tprof_type.Properties.GetByName("ACCS_Ld_fast_Tprof_Tvst")
Time = Tvst.Properties.GetByName("ACCS_Ld_fast_Tprof_Tvst_Time")
Temperature = Tvst.Properties.GetByName("ACCS_Ld_fast_Tprof_Tvst_Temperature")
while 0 < Tvst.RowCount:
Tvst.DeleteRow(0)
for pt in Tprof:
Tvst.AddRow()
Time.Value = pt[0]
Temperature.Value = pt[1]
Tvst.SaveActiveRow()
Tvst.Validate()
[docs]
def setViscoElasticity(self, v):
"""Activates or deactivate the viscoelasticity.
:param v: The viscoelasticity will be activated if True
:type v: bool
.. note::
The corresponding properties do need to have been defined in Engineering Data.
"""
if self.uObj.Analysis.PhysicsType == "Thermal":
raise RuntimeError(
"The ACCS analysis type can only be set for a Mechanical analysis."
)
if (
v
not in self.uObj.Properties["ACCS_Ld_SelectType/ACCS_Ld_full_visco"].Options
):
raise RuntimeError(
"The analysis type must be among these valid options: "
+ str(self.uObj.Properties["ACCS_Ld_SelectType"].Options)
)
self.set_property("ACCS_Ld_SelectType/ACCS_Ld_full_visco", v)
class _ACCSGeoSelectionLoad(_ACCSObj):
def __init__(self, uObj, tObj):
_ACCSObj.__init__(self, uObj, tObj)
def setSurfacesByGeoSelection(self, selection):
"""Sets the surfaces where it applies via Geometry Selection.
:param selection: The selected surfaces
:type selection: SelectionInfo
"""
self.set_property("Geometry/DefineBy", "ID_GeometrySelection")
self.set_property("Geometry/DefineBy/Geo", selection)
def setSurfacesByNamedSelection(self, selection):
"""Sets the surfaces where it applies via Named Selection.
:param selection: Instance or ID reference to the named selection containing the surfaces
:type selection: NamedSelection or NamedSelection ID
"""
if isinstance(selection, _Ansys.ACT.Automation.Mechanical.NamedSelection):
selection = selection.Id
self.set_property("Geometry/DefineBy", "ID_NamedSelection")
self.set_property("Geometry/DefineBy/NamedSelection", selection)
class RTMOutletLoad(_ACCSGeoSelectionLoad):
"""RTM Outlet load class
Class to use to script the RTM Outlet load from Mechanical
"""
def __init__(self, uObj, tObj):
_ACCSGeoSelectionLoad.__init__(self, uObj, tObj)
class RTMInletLoad(_ACCSGeoSelectionLoad):
"""RTM Inlet load class
Class to use to script the RTM Inlet load from Mechanical
"""
def __init__(self, uObj, tObj):
_ACCSGeoSelectionLoad.__init__(self, uObj, tObj)
def setConstant(self, value):
if self.uObj.Name == "PressureInlet":
group_name = "ACCS_RTM_InletPressure"
var_name = "ACCS_RTM_InletPressure_Cst"
else:
group_name = "ACCS_RTM_InletFlowrate"
var_name = "ACCS_RTM_InletFlowrate_Cst"
self.set_property(group_name, "Constant")
self.set_property(group_name + "/" + var_name, float(value))
def setTimeConditionOnFill(self, steps):
"""Sets a time condition for the RTM Inlet as OnFill
:param steps: The cure cycle shall be defined with a list of steps. A step can be defined as [X, Y] where X is the time for the step, and Y is the pressure/flowrate. For onFill, the first entry will only have Y.
:type steps: list[step].
"""
self._setTimeCondition("OnFill", steps)
def setTimeConditionTabular(self, steps):
"""Sets a time condition for the RTM Inlet as Tabular
:param steps: The cure cycle shall be defined with a list of steps. A step can be defined as [X, Y] where X is the time for the step, and Y is the pressure/flowrate. For onFill, the first entry will only have Y.
:type steps: list[step].
"""
self._setTimeCondition("Tabular", steps)
def _setTimeCondition(self, methodType, steps):
"""Sets a time condition for the RTM Inlet
:param steps: The cure cycle shall be defined with a list of steps. A step can be defined as [X, Y] where X is the time for the step, and Y is the pressure/flowrate. For onFill, the first entry will only have Y.
:type steps: list[step].
:param methodType: The type of time condtion "OnFill" or "Tabular
:type methodType: String.
"""
if self.uObj.Name == "PressureInlet":
group_name = "ACCS_RTM_InletPressure"
prop_name = "ACCS_RTM_InletPressure_Tab"
time_var_name = "ACCS_RTM_InletPressure_Tab_Time"
data_type_name = "ACCS_RTM_InletPressure_Tab_Pressure"
else:
group_name = "ACCS_RTM_InletFlowrate"
prop_name = "ACCS_RTM_InletFlowrate_Tab"
time_var_name = "ACCS_RTM_InletFlowrate_Tab_Time"
data_type_name = "ACCS_RTM_InletFlowrate_Tab_Flowrate"
prop_group = self.uObj.Properties[group_name]
if methodType == "OnFill":
prop_name = prop_name + "_on_full"
prop_group.Value = "OnFill"
else:
prop_group.Value = "Tabular"
Table = prop_group.Properties[prop_name]
var_field = Table.Properties[data_type_name]
time_field = Table.Properties[time_var_name]
while 0 < Table.RowCount:
Table.DeleteRow(0)
for s in steps:
if Table.RowCount == 0 and methodType == "OnFill":
time_field_val = -1
else:
time_field_val = float(s[0])
Table.AddRow()
time_field.Value = time_field_val
var_field.Value = float(s[1])
Table.SaveActiveRow()
class RTM_Thermal_Import(_ACCSFilePathObj, _ACCSGeoSelectionLoad):
"""ACCS RTM thermal result importer class
Class to use to script the RTM thermal result importer from Mechanical
"""
def __init__(self, uObj, tObj):
_ACCSFilePathObj.__init__(self, uObj, tObj)
_ACCSGeoSelectionLoad.__init__(self, uObj, tObj)
def set_thermal_filepath(self, filepath):
"""Sets the path to the user given path.
:param filepath: The full path or relative path defining where the thermal result file is located.
:type filepath: string
"""
if self.path_exist(filepath):
self.set_property("ThermalFileProp", str(filepath))
class RTM_Result_Import(_ACCSFilePathObj):
"""ACCS RTM result importer class
Class to use to script the RTM result importer from Mechanical
"""
def __init__(self, uObj, tObj):
_ACCSFilePathObj.__init__(self, uObj, tObj)
def set_result_filepath(self, filepath):
"""Sets the path to the user given path.
:param filepath: The full path or relative path defining where the RTM result file is located.
:type filepath: string
"""
if self.path_exist(filepath):
self.set_property("ResultFileProp", str(filepath))
class RTM_Result_Export(_ACCSFilePathObj, _ACCSGeoSelectionLoad):
"""ACCS RTM result exporter class
Class to use to script the RTM result exporter from Mechanical
"""
def __init__(self, uObj, tObj):
_ACCSFilePathObj.__init__(self, uObj, tObj)
_ACCSGeoSelectionLoad.__init__(self, uObj, tObj)
def set_result_filepath(self, filepath):
"""Sets the path to the user given path.
:param filepath: The full path or relative path defining where the RTM result file is located.
:type filepath: string
"""
if self.path_exist(filepath):
self.set_property("RTM_Export_Fp", str(filepath))
[docs]
class ACCSsuprem(_ACCSObj):
"""ACCS support remover class
Class to use to script the ACCS support remover from Mechanical
"""
def __init__(self, uObj, tObj):
_ACCSObj.__init__(self, uObj, tObj)
[docs]
def setStep(self, step):
"""Defines when will the support remover will be active.
:param step: The step number
:type step: scalar
"""
step = str(step)
if step not in self.uObj.Properties["ACCS_SupRem_Step"].Options:
raise RuntimeError(
"The step number must be among these valid options: "
+ str(self.uObj.Properties["ACCS_SupRem_Step"].Options)
)
self.set_property("ACCS_SupRem_Step", step)
[docs]
def setSurfacesByGeoSelection(self, selection):
"""Sets the surfaces where it applies via Geometry Selection.
:param selection: The selected surfaces
:type selection: SelectionInfo
"""
self.set_property("ACCS_SupRem_Geometry/DefineBy", "ID_GeometrySelection")
self.set_property("ACCS_SupRem_Geometry/DefineBy/Geo", selection)
[docs]
def setSurfacesByNamedSelection(self, selection):
"""Sets the surfaces where it applies via Named Selection.
:param selection: Instance or ID reference to the named selection containing the surfaces
:type selection: NamedSelection or NamedSelection ID
"""
if isinstance(selection, _Ansys.ACT.Automation.Mechanical.NamedSelection):
selection = selection.Id
self.set_property("ACCS_SupRem_Geometry/DefineBy", "ID_NamedSelection")
self.set_property("ACCS_SupRem_Geometry/DefineBy/NamedSelection", selection)
[docs]
class ACCSsurexp(_ACCSObj):
"""ACCS support remover class
Class to use to script the ACCS support remover from Mechanical
"""
def __init__(self, uObj, tObj):
_ACCSObj.__init__(self, uObj, tObj)
[docs]
def setExportPath(self, filepath):
"""Sets the path to the exported path.
:param filepath: The full path or relative path defining where the file will be saved
:type filepath: string
"""
self.set_property("ACCS_ExpSurf_FilePath", filepath)
[docs]
def setSurfacesByGeoSelection(self, selection):
"""Sets the surfaces where it applies via Geometry Selection.
:param selection: The selected surfaces
:type selection: SelectionInfo
"""
self.set_property("ACCS_ExpSurf_Geometry/DefineBy", "ID_GeometrySelection")
self.set_property("ACCS_ExpSurf_Geometry/DefineBy/Geo", selection)
[docs]
def setSurfacesByNamedSelection(self, selection):
"""Sets the surfaces where it applies via Named Selection.
:param selection: Instance or ID reference to the named selection containing the surfaces
:type selection: NamedSelection or NamedSelection ID
"""
if isinstance(selection, _Ansys.ACT.Automation.Mechanical.NamedSelection):
selection = selection.Id
self.set_property("ACCS_ExpSurf_Geometry/DefineBy", "ID_NamedSelection")
self.set_property("ACCS_ExpSurf_Geometry/DefineBy/NamedSelection", selection)
class ACCSinistate(_ACCSObj):
"""ACCS inistate importer class
Class to use to script the ACCS inistate importer from Mechanical
"""
def __init__(self, uObj, tObj):
_ACCSObj.__init__(self, uObj, tObj)
def setISTPath(self, filepath):
"""Sets the path to the *.IST file.
:param filepath: The full or relative path to the *.IST file
:type filepath: string
"""
self.set_property("ACCS_IniSta_FilePath", filepath)
def setStep(self, step):
"""Defines when will the inistate importer will be active.
:param step: The step number
:type step: scalar
"""
step = str(step)
if step not in self.uObj.Properties["ACCS_IniSta_Step"].Options:
raise RuntimeError(
"The step number must be among these valid options: "
+ str(self.uObj.Properties["ACCS_IniSta_Step"].Options)
)
self.set_property("ACCS_IniSta_Step", step)