Main Content

digitalthread.uri.simulink.toObject

R2026b

Convert digital thread URI to Simulink object

Since R2026b

    Description

    obj = digitalthread.uri.simulink.toObject(storageMap,uri) returns the Simulink® object identified by the digital thread URI and loads the associated model.

    A digital thread URI is a stable identifier for an artifact, such as a model, or an artifact within that file, such as a block. The digital thread uses these URIs as a consistent way to refer to artifacts across tools and inside metric results.

    Use this function to retrieve the Simulink object identified by the digital thread URI. You can then work directly with that model element.

    Note

    The URI must identify a specific element within the model, such as a block or subsystem. This function does not support the URI of a model file. To get the file path for a URI of a model file, use digitalthread.uri.toAbsoluteFilePath instead.

    You might already have a digital thread URI of interest from your metric results. If not, you can get the digital thread URI from a specific Simulink element by using the other functions in the digitalthread.uri.simulink namespace, such as digitalthread.uri.simulink.fromObject.

    obj = digitalthread.uri.simulink.toObject(___,Load=false) returns the Simulink object without loading the model.

    example

    Examples

    collapse all

    Suppose you already have a digital thread URI for a Simulink model or element that appears in your metric results. You can get the associated Simulink object by using the digitalthread.uri.simulink.toObject function.

    For example, suppose the ScopeId property for one of your metric results shows a digital thread URI mwdigitalthread://myProject/myModel.slx#addr=myModel/1 and you save that URI to a variable.

    myURI = "mwdigitalthread://myProject/myModel.slx#addr=myModel/1";

    Create a storage map for the current project.

    storageMap = digitalthread.StorageMap.forProject();

    Find the Simulink object associated with that digital thread URI.

    myObj = digitalthread.uri.simulink.toObject(storageMap,myURI)
    myObj = 
    
      SubSystem with properties:
    
        Name: 'mySubsystem'

    You can use the object properties and Simulink functions, such as open_system and hilite_system, to work directly with the object.

    Input Arguments

    collapse all

    Storage map, specified as a digitalthread.StorageMap object.

    A storage map defines how digital thread URIs map to the actual artifact locations. The storage map determines which artifacts the digital thread can reference, trace, and associate with metric results.

    To create a storage map, use digitalthread.StorageMap.forProject.

    Example: digitalthread.StorageMap.forProject()

    Digital thread URI for Simulink object, returned as a string scalar.

    You can get digital thread URIs from metric results, functions in the digitalthread.uri.simulink namespace, and other functions in the digitalthread.uri namespace.

    Example: "mwdigitalthread://myProject/myModel.slx#addr=myModel/123:45"

    Data Types: string

    Output Arguments

    collapse all

    Simulink object, such as a model, block, or subsystem, returned as a Simulink object.

    Version History

    Introduced in R2026b