Documentation

slproject.loadProject

Load Simulink project

Syntax

  • slproject.loadProject(projectPath);
    example
  • proj = slproject.loadProject(projectPath)
    example

Description

example

slproject.loadProject(projectPath); loads the project specified by the .prj file or folder projectPath in the Simulink® 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.

sldemo_slproject_airframe
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.

sldemo_slproject_airframe
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.

sldemo_slproject_airframe
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.mdl'
            Data: []
        DataType: 'none'
            Name: 'Design'
    CategoryName: 'Classification'

Get a particular file by name.

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

  ProjectFile with properties:

      Path:  'C:\Temp\airframe\models\AnalogControl.mdl'
    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 Simulink 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

Introduced in R2013a


Was this topic helpful?