How to import Spaceclaim API packages in ACT?
Best Answer
-
By executing the "LoadSCDMAPITypesV19.py" (for v19). One can find these executable in the installation directory: "C:\Program Files\ANSYS Inc\v202\scdm\Scripting"
Refer to TIG Customization post from David Pons on 13.10.20
#Import V19 API into the module. clr.AddReference("Ans.Core") clr.AddReference("Ans.Utilities") VersionStr = Ansys.Utilities.ApplicationConfiguration.DefaultConfiguration.VersionInfo.VersionString InstallDir = os.environ["AWP_ROOT"+VersionStr] + "\scdm" ScriptingDir = os.path.join(InstallDir,"Scripting") execfile("LoadSCDMAPIModuleV19.py") execfile(os.path.join(ScriptingDir,"LoadSCDMAPITypesV19.py")) execfile("LoadSCDMAPIUtilitiesV19.py") execfile(os.path.join(ScriptingDir,"UtilitiesOnLoadV19.py"))
6
Answers
-
For v232 this fails on line 4 when Ansys is not defined:
`VersionStr = Ansys.Utilities.ApplicationConfiguration.DefaultConfiguration.VersionInfo.VersionString
name 'Ansys' is not defined`
0 -
For Ansys 23 i get the following error for "execfile("LoadSCDMAPIModuleV23.py")"
No module named Scripting
Is there a way to solve this?0 -
@Valérie Gelbgras @Gabriel Messager maybe you can help here?
0 -
In case someone need more information, here is the code that i try to run in the spaceclaim script:
#
import clr
import units
import time
import osclr.AddReference("SpaceClaim.Api.V23")
clr.AddReference("Ans.Core")
clr.AddReference("Ans.Utilities")VersionStr = Ansys.Utilities.ApplicationConfiguration.DefaultConfiguration.VersionInfo.VersionString
InstallDir = os.environ["AWP_ROOT"+VersionStr] + "\scdm"
ScriptingDir = os.path.join(InstallDir,"Scripting")execfile(os.path.join(ScriptingDir,"LoadSCDMAPITypesV23.py"))
execfile(os.path.join(ScriptingDir,"UtilitiesOnLoadV23.py"))#
when i try to execute the code in directly in the console i get the above mentioned error:
No module named ScriptingWhen i try to import the extension (its a wizard extension for spaceclaim) i get the following error in the ACT Log:
#
Die Datei oder Assembly "ScriptingFoundation, Version=0.1.0.0, Culture=neutral, PublicKeyToken=429fe67ab88e56ed" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
FileNotFoundException
bei System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
bei System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
bei System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
bei System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
bei System.Reflection.CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean mustBeInheritable)
bei System.Reflection.CustomAttribute.IsDefined(RuntimeType type, RuntimeType caType, Boolean inherit)
bei IronPython.Runtime.Types.PythonType.InitializeSystemType()
bei IronPython.Runtime.Types.PythonType.GetPythonType(Type type)
bei IronPython.Runtime.Types.PythonType.AddSystemBases()
bei IronPython.Runtime.Types.PythonType.GetPythonType(Type type)
bei IronPython.Runtime.Types.PythonType.AddSystemInterfaces(List1 mro) bei IronPython.Runtime.Types.PythonType.AddSystemBases() bei IronPython.Runtime.Types.PythonType.GetPythonType(Type type) bei IronPython.Runtime.Types.PythonType.AddSystemBases() bei IronPython.Runtime.Types.PythonType.GetPythonType(Type type) bei IronPython.Runtime.Types.PythonType.AddSystemBases() bei IronPython.Runtime.Types.PythonType.GetPythonType(Type type) bei IronPython.Runtime.Types.PythonType.AddSystemBases() bei IronPython.Runtime.Types.PythonType.GetPythonType(Type type) bei IronPython.Runtime.Operations.PythonTypeOps.GetSlot(MemberGroup group, String name, Boolean privateBinding) bei IronPython.Runtime.Operations.NamespaceTrackerOps.GetCustomMember(CodeContext context, NamespaceTracker self, String name) bei IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object from, String name) bei Microsoft.Scripting.Interpreter.FuncCallInstruction
4.Run(InterpretedFrame frame)
bei Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
bei Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
bei Microsoft.Scripting.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame) bei Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) bei Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3) bei System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) bei Microsoft.Scripting.Interpreter.DynamicInstruction
4.Run(InterpretedFrame frame)
bei Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
bei Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
bei IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
bei Ansys.ACT.Core.Extension.ReadScripts()#
0