How to see which ACT Extensions are loaded with Workbench Journaling
Is there a way to check if a particular extension is already loaded (in 2023 R2)?
I have tried to do a try: except
catch with Extensions.LoadExtensions
but that isn't working for some reason:
try: Extensions.LoadExtension( Id="04a2fd24-d76b-45c8-8553-be985906c975", Version="232.12", Format="Scripted" ) except Exception as exc: if "Unable to find extension" in str(exc): raise RuntimeError("CloudConnect not installed.") # Message when extension is already loaded if "An error occurred during loading the EDRMedeso CloudConnect extension" in str(exc): pass
I tried using different exceptions as well
System.Exception
Ansys.Core.Scripting.ScriptingException
This is the error im getting from Workbench
System.Exception: The extension EDRMedeso CloudConnect is already loaded. at Ansys.ACT.WorkBench.NativeManager.LoadExtension(IExtensionDefinition definition) --- System.Exception: An error occurred during loading the EDRMedeso CloudConnect extension. at Ansys.ACT.WorkBench.NativeManager.LoadExtension(IExtensionDefinition definition) at Ansys.ACT.WorkBench.Commands.LoadExtensionCommand.Execute(IFullContext context) at Ansys.Core.Commands.Concurrency.CommandWorkUnit.executeInContext(CommandContext subContext, IExecutionEngineCallback tracer) at Ansys.Core.Commands.Concurrency.BaseWorkUnit.doExecute(IExecutionEngineCallback executionEngine, CommandContext subContext) at Ansys.Core.Commands.Concurrency.BaseWorkUnit.Execute(IExecutionEngineCallback executionEngine, Boolean dontCatchExceptions) --- Ansys.Core.Commands.CommandFailedException: An error occurred during loading the EDRMedeso CloudConnect extension. CommandName: Extensions.LoadExtension(Id="04a2fd24-d76b-45c8-8553-be985906c975", Version="232.12", Format="Scripted") at Microsoft.Scripting.Runtime.LightExceptions.ThrowException(LightException lightEx) at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object value) at __call__$684(Closure , PythonFunction , Object , Object , Object ) at Microsoft.Scripting.Interpreter.FuncCallInstruction`6.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run7[T0,T1,T2,T3,T4,T5,T6,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) at Microsoft.Scripting.Interpreter.DynamicInstruction`7.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run6[T0,T1,T2,T3,T4,T5,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) at Microsoft.Scripting.Interpreter.DynamicInstruction`6.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run6[T0,T1,T2,T3,T4,T5,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) at Microsoft.Scripting.Interpreter.DynamicInstruction`6.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1) at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx) at Microsoft.Scripting.Hosting.CompiledCode.Execute[T](ScriptScope scope) at Ansys.PythonScriptingEngine.PythonScriptingEngine.ExecuteFile(String fileName) --- Ansys.Core.Scripting.ScriptingException: CommandFailedException: An error occurred during loading the EDRMedeso CloudConnect extension. In file "D:\test.wbjn", line 4 Traceback (most recent call last): File "D:\test.wbjn", line 4, in <module> File "C:\Program Files\ANSYS Inc\v232\Addins\PythonScriptingEngine\PythonFiles\CommandBindings.py", line 54, in __call__ Exception: An error occurred during loading the EDRMedeso CloudConnect extension. at Microsoft.Scripting.Runtime.LightExceptions.ThrowException(LightException lightEx) at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object value) at __call__$684(Closure , PythonFunction , Object , Object , Object ) at Microsoft.Scripting.Interpreter.FuncCallInstruction`6.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run7[T0,T1,T2,T3,T4,T5,T6,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) at Microsoft.Scripting.Interpreter.DynamicInstruction`7.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run6[T0,T1,T2,T3,T4,T5,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) at Microsoft.Scripting.Interpreter.DynamicInstruction`6.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run6[T0,T1,T2,T3,T4,T5,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) at Microsoft.Scripting.Interpreter.DynamicInstruction`6.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1) at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx) at Microsoft.Scripting.Hosting.CompiledCode.Execute[T](ScriptScope scope) at Ansys.PythonScriptingEngine.PythonScriptingEngine.ExecuteFile(String fileName) --- Ansys.Core.Commands.CommandFailedException: CommandFailedException: An error occurred during loading the EDRMedeso CloudConnect extension. In file "D:\test.wbjn", line 4 CommandName: RunScript(FilePath="D:/test.wbjn") at Ansys.Core.Commands.CommandAsyncResult.RethrowFailureException(Exception e) at Ansys.Core.Commands.CommandAsyncResult.Wait(Int32 milliSecondsTimeout, Boolean exitContext) at Ansys.Core.Commands.Standard.RunScriptCommand.InvokeAndWait(IProtectedContext context, String FilePath) at Ansys.UI.Standard.RecentScriptFilesGui.Invoke(GuiOperationContext context, GuiOperationArgs args) at Ansys.UI.GuiOperationContext.Invoke(GuiOperationMetaData operationData) at Ansys.UI.UIManager.InvokeOperationCore(String pseudoname, OperationDelegate callback, Boolean allowOSMessages, Boolean coreTransaction, Boolean deferredRefreshOnly)
Best Answer
-
I just realized I was running a script file I had recorded, without the exception catching, that had the same name, but was in a different folder...
PEBCAK, the code in my question and your answer works as intended.
Apologies for the confusion.
0
Answers
-
try: Extensions.LoadExtension(Id=ext_id.ToLower()) except Exception as exc: if "Unable to find extension" in str(exc): print "Extension not installed." elif "An error occurred during loading " in str(exc): print "Extension is already loaded." else: print "Unknown error loading extension."
1 -
@Landon Mitchell Kanner said:
try: Extensions.LoadExtension(Id=ext_id.ToLower()) except Exception as exc: if "Unable to find extension" in str(exc): print "Extension not installed." elif "An error occurred during loading " in str(exc): print "Extension is already loaded." else: print "Unknown error loading extension."
Still having the same issue as in my original post, the exception catch is not working.
Im running the journal from
File -> Scripting -> Run Script File...
if that makes a difference0 -
print statement will not work when using "Run Script File...", but the methodology is working on my end.
What do you mean, "the exception catch is not working" ?0 -
How about this?
for Ext in ExtAPI.ExtensionManager.Extensions: print Ext.UniqueId
0 -
@Mike.Thompson said:
How about this?for Ext in ExtAPI.ExtensionManager.Extensions: print Ext.UniqueId
Is there a way to access EXTApi in WB journaling?
0 -
This script works for me in WB ACT console. "Journaling" is simply python scripting in WB. Journaling is a term used because you can record actions of the UI, but more often people use "scripting". I think this implies not only recording, but also building scripts from scratch. Either way, whatever you call it, it is the same thing.
Be sure to use proper capitalization as python is case sensitive. You can directly use "ExtAPI" in WB scripting/journaling.
for Ext in ExtAPI.ExtensionManager.Extensions: print Ext.UniqueId
0 -
I see, I was trying to run it in "journaling console" (
File -> Scripting -> Open Command Window
), since that's what were are using for the current project. Sorry for mismatching the terms there.I tied it in the WB ACT console as well and that seems to working as intended, thanks!
0 -
The ACT console has many variables pre-defined that are not initially defined in WB scripting. Here is how to define ExtAPI in WB scripting (outside of ACT):
https://discuss.ansys.com/discussion/1444/is-it-possible-to-access-extapi-from-the-project-context-in-workbench0