How to import Spaceclaim API packages in ACT?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 444
250 Likes Solution Developer Community of Practice Member Ansys Employee First Anniversary
✭✭✭✭
edited June 2023 in 3D Design

How to import Spaceclaim API packages in ACT?

Tagged:

Best Answer

Answers

  • M
    M Member, Employee Posts: 235
    100 Comments Photogenic 5 Likes Name Dropper
    ✭✭✭✭
    edited January 8

    For v232 this fails on line 4 when Ansys is not defined:

    `VersionStr = Ansys.Utilities.ApplicationConfiguration.DefaultConfiguration.VersionInfo.VersionString

    name 'Ansys' is not defined`

  • Niklas
    Niklas Member Posts: 2
    First Comment
    **

    For Ansys 23 i get the following error for "execfile("LoadSCDMAPIModuleV23.py")"
    No module named Scripting
    Is there a way to solve this?

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 444
    250 Likes Solution Developer Community of Practice Member Ansys Employee First Anniversary
    ✭✭✭✭

    @Valérie Gelbgras @Gabriel Messager maybe you can help here?

  • Niklas
    Niklas Member Posts: 2
    First Comment
    **
    edited April 12

    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 os

    clr.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 Scripting

    When 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.FuncCallInstruction4.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.DynamicInstruction4.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()

    #