Best way to save a Viewer URL as attribute

Options
Remi.Mesnildrey
Remi.Mesnildrey Member, Employee Posts: 5
Name Dropper First Comment Photogenic
edited October 2023 in Materials

Scenario: A customer is looking to store in their datasheets a Viewer URL to the same datasheets. This is to have that URL easily available to any export processes they might have. If using the MI Python STK to do this, i imagine the script to be something like "for all records in this table, read their url and import it in this hyperlink attribute".

Question: The question is what would be the best way to read the viewer url of a record? The viewer_url property of a record looks perfect for that on paper but is there any catch? Is there an even simpler way?

Tagged:

Answers

  • Doug Addy
    Doug Addy Member, Employee Posts: 21
    First Anniversary Name Dropper First Answer Ansys Employee
    edited October 2023
    Options

    There are several ways to get a URL for a Viewer datasheet, it depends on whether your MI Viewer is installed at the default path and whether you need this information for one or many records.

    The Record.viewer_url property makes a reasonable attempt to create this link for you, and in most cases will work out of the box. It's also relatively performant. The only issue you may encounter is that if you are using a Version-Controlled table you will always get the latest visible version of a record.

    If your MI Viewer is installed somewhere other than /mi then you will need to create the URL yourself. The implementation in Record.viewer_url will provide a starting point.

    You can also make use of the foundation layer GetDatasheetPath operation, which takes a list of record references and optionally a UnitConversionContext it will return a list of relative paths which you can combine with the base MI Viewer address. This can set the unit system and the currency for the datasheet directly.

  • Remi.Mesnildrey
    Remi.Mesnildrey Member, Employee Posts: 5
    Name Dropper First Comment Photogenic
    Options

    Thanks @Doug Addy !
    The standard /mi is used and while it is a version-controlled table, their purpose of putting a link in a non-maintained exported file is to make sure people can easily check whether the data they have is the most up-to-date so it shouldn't be an issue to only get the latest version.

    What alternatives would exist in case they need links to specifc versions? Could we build the correct URL with the recordGUID and historyGUID?

  • VEtique
    VEtique Member, Employee Posts: 8
    Name Dropper First Anniversary First Comment Ansys Employee
    Options

    Hi @Remi.Mesnildrey ,
    I think you could use the record guid as specified in the documentation of MI_Viewer HPA .
    If you get the dbkey and the recordGUID, you can then create a link to any record version by using a link structured as follows:
    https://servername/datasheet.aspx?dbkey=MI_Training&recordGuid=000001bf-000e-4fff-8fff-b5e2ffff0000

  • Remi.Mesnildrey
    Remi.Mesnildrey Member, Employee Posts: 5
    Name Dropper First Comment Photogenic
    Options

    Thanks @VEtique !