The script in Spaceclaim encountered an error in the ACT Stage Page

zggnph
zggnph Member Posts: 7
Name Dropper First Comment
**

I developed a script that can run on SpaceClaim, but when the script is integrated into the ACT Stage Page, the following error is reported.

Comments

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 297
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
  • zggnph
    zggnph Member Posts: 7
    Name Dropper First Comment
    **

    This operation has already been executed, still reporting this error.

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 297
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited July 17

    Try this:

    import os, sys
    clr.AddReference("Ans.Utilities")
    from Ansys.Utilities import ApplicationConfiguration
    version = ApplicationConfiguration.DefaultConfiguration.VersionInfo.VersionString
    
    sys.path.append(os.environ["AWP_ROOT"+version]+"/scdm/Scripting")
    clr.AddReference("SpaceClaim.Api.V{}".format(version))
    clr.AddReference("SpaceClaim.Api.V{}.Scripting".format(version))
    exec('from LoadSCDMAPITypesV{} import *'.format(version))
    exec('from UtilitiesOnLoadV{} import *'.format(version))
    
    
    exec('from SpaceClaim.Api.V{}.Scripting import Extensions'.format(version))
    exec('arg = SpaceClaim.Api.V{}.Scripting.Extensions'.format(version))
    clr.ImportExtensions(arg)
    
    GetRootPart().GetComponents()
    

    If it works on your end, I will file a bug to add:

    from SpaceClaim.Api.V241.Scripting import Extensions
    clr.ImportExtensions(SpaceClaim.Api.V241.Scripting.Extensions)
    

    to LoadSCDMAPITypesV241.py

  • zggnph
    zggnph Member Posts: 7
    Name Dropper First Comment
    **

    @Landon Mitchell Kanner said:
    Try this:

    import os, sys
    clr.AddReference("Ans.Utilities")
    from Ansys.Utilities import ApplicationConfiguration
    version = ApplicationConfiguration.DefaultConfiguration.VersionInfo.VersionString
     
    sys.path.append(os.environ["AWP_ROOT"+version]+"/scdm/Scripting")
    clr.AddReference("SpaceClaim.Api.V{}".format(version))
    clr.AddReference("SpaceClaim.Api.V{}.Scripting".format(version))
    exec('from LoadSCDMAPITypesV{} import *'.format(version))
    exec('from UtilitiesOnLoadV{} import *'.format(version))
    
    
    exec('from SpaceClaim.Api.V{}.Scripting import Extensions'.format(version))
    exec('arg = SpaceClaim.Api.V{}.Scripting.Extensions'.format(version))
    clr.ImportExtensions(arg)
    
    GetRootPart().GetComponents()
    

    If it works on your end, I will file a bug to add:

    from SpaceClaim.Api.V241.Scripting import Extensions
    clr.ImportExtensions(SpaceClaim.Api.V241.Scripting.Extensions)
    

    to LoadSCDMAPITypesV241.py

    The problem has been solved using this method, thank you.

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 297
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    The Ansys team has decided not to fix this bug, because there is a workaround and because SpaceClaim and SpaceClaim ACT are in maintenance mode. We recommend starting to transition SpaceClaim ACT usage to the Discovery customization functionality, which uses the same script editor and provides more functionality, including an extension builder.