Main Content

slproject.loadProject

(Not recommended) Load project

simulinkproject is not recommended. Use currentProject or openProject instead. For more information, see Compatibility Considerations.

Description

example

slproject.loadProject(projectPath); loads the project specified by the .prj file or folder projectPath in the Project Tool, and closes any currently open project.

example

proj = slproject.loadProject(projectPath) loads the project and returns a project object proj for manipulating the project. Use slproject.loadProject for project automation scripts.

Examples

collapse all

Load a project from a folder called 'C:/projects/project1/'. Replace this path with the location of your project.

proj = slproject.loadProject('C:/projects/project1/')

Open the Airframe project and use slproject.getCurrentProjects to get a project object to manipulate the project at the command line.

openExample('simulink/AirframeProjectExample')
proj = slproject.getCurrentProjects
proj = 

  ProjectManager with properties:

          Name: 'Simulink Project Airframe Example'
           Categories: [1x1 slproject.Category]
            Shortcuts: [1x8 slproject.Shortcut]
          ProjectPath: [1x7 slproject.PathFolder]
    ProjectReferences: [1x0 slproject.ProjectReference]
                Files: [1x30 slproject.ProjectFile]
           RootFolder: 'C:\Work\Simulink\Projects\airframe'

Get the Airframe project.

openExample('simulink/AirframeProjectExample')
proj = slproject.getCurrentProjects;

Find project commands.

methods(proj)
Methods for class slproject.ProjectManager:

addFile                       findCategory        
addFolderIncludingChildFiles  findFile            
close                         isLoaded            
createCategory                listModifiedFiles   
export                        refreshSourceControl


reload
removeCategory
removeFile    

After you get a project object, you can examine project properties.

Get the airframe project.

openExample('simulink/AirframeProjectExample')
proj = slproject.getCurrentProjects;

Examine the project files.

files = proj.Files
files = 

  1x30 ProjectFile array with properties:

    Path
    Labels
    Revision
    SourceControlStatus

Examine the labels of the 13th file.

proj.Files(13).Labels
ans = 

  Label with properties:

File:  'C:\Temp\airframe\models\AnalogControl.slx'
            Data: []
        DataType: 'none'
            Name: 'Design'
    CategoryName: 'Classification'

Get a particular file by name.

myfile = findFile(proj, 'models/AnalogControl.slx')
myfile = 

  ProjectFile with properties:

      Path:  'C:\Temp\airframe\models\AnalogControl.slx'
    Labels: [1x1 slproject.Label]
  Revision: '2'
SourceControlStatus: Unmodified

Find out what you can do with the file.

methods(myfile)
Methods for class slproject.ProjectFile:

addLabel
removeLabel
findLabel

Input Arguments

collapse all

Full path to project .prj file or the path to the project root folder, specified as a character vector.

Example: 'C:/projects/project1/myProject.prj'

Example: 'C:/projects/project1/'

Output Arguments

collapse all

Project, returned as a project object. Use the project object to manipulate and explore the project at the command line.

Properties of proj output argument.

Project PropertyDescription
NameProject name
CategoriesCategories of project labels
ShortcutsShortcut files in project
ProjectPath

Folders that the project puts on the MATLAB® path 

ProjectReferencesFolders that contain referenced projects 
FilesPaths and names of project files
RootFolderFull path to project root folder

Version History

Introduced in R2013a

collapse all

R2019a: Simulink project API is not recommended

Starting in R2019a, instead of simulinkproject and related functions, use the currentProject or openProject functions in MATLAB. The Simulink® project API will continue to be supported, but, after R2019a, new features will be available only if you use the new MATLAB project API. There are no plans to remove the Simulink project API at this time.

You can continue to use simulinkproject and related functions listed in methods(simulinkproject). New functions added after R2019a, such as runChecks and listImpactedFiles, do not work with simulinkproject. Use currentProject instead.

The new MATLAB project API is part of the R2019a functionality enabling you to use projects in MATLAB, with or without Simulink. You can now share projects with users who do not have Simulink.