Using the DocumentOpen.Execute(r"---") to open a document

RK
RK Member, Employee Posts: 11
First Comment Name Dropper
✭✭✭

Answers

  • RK
    RK Member, Employee Posts: 11
    First Comment Name Dropper
    ✭✭✭

    When recording a script in SpaceClaim, Documentopen.Execute(r"____") for relative path or Documentopen.Execute("____") for absolute path is written. I remember this script working in previous versions, however, in 23R1, this does not seem to be working, even with the latest API. Any help on this is appreciated. Thank you!

  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 85
    Photogenic 5 Likes Name Dropper Ansys Employee
    ✭✭✭✭

    @RK

    The 'r' prefix in the path string is not for relative path. It asks python to consider path as raw string.

    If you give absolute path with 'r' in as prefix then it should work. If you do not use 'r' then I would suggest you to use forward slash "/" instead of backward slash "\". When using backward slash , it would consider string based on string literals. https://docs.python.org/2/reference/lexical_analysis.html#grammar-token-stringliteral

    The DocumentOpen.Execute API works as expected in 2023R1.

  • RK
    RK Member, Employee Posts: 11
    First Comment Name Dropper
    ✭✭✭

    Hello @Rajesh Meena , thank you again for your response!

    I tried this script to read in a geometry located in the D drive:

    DocumentOpen.Execute(r"D:\test\Geom\fins-1-0139 - Copy.scdoc", FileSettings1)

    I am still unable to load the geometry. Any suggestions as to where I am going wrong?