Documentation Center

  • Trial Software
  • Product Updates

slproject.getCurrentProject

Manipulate current Simulink Project at command line

Syntax

  • proj = slproject.getCurrentProject example

Description

example

proj = slproject.getCurrentProject gets the current project open in the Simulink® Project Tool and returns a project object proj that you can use to manipulate the project programmatically. Use slproject.getProject for project automation scripts.

Examples

expand all

Get Airframe Example Project

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

sldemo_slproject_airframe
proj = slproject.getCurrentProject
proj = 

  ProjectManager with properties:

          Name: 'Simulink Project Airframe Example'
   Categories: [1x2 slproject.Category]
     Shortcuts: [1x6 slproject.Shortcut]
             Files: [1x24 slproject.ProjectFile]
   RootFolder: 'C:\Temp\20121107T135235\airframe'

Find Project Commands

Open the airframe project and create a project object.

sldemo_slproject_airframe
proj = slproject.getCurrentProject
proj = 

  ProjectManager with properties:

          Name: 'Simulink Project Airframe Example'
    Categories: [1x2 slproject.Category]
         Files: [1x24 slproject.ProjectFile]
    RootFolder: [1x61 char]

Find out what you can do with your project.

methods(proj)
Methods for class slproject.ProjectManager:

addFile
export
isLoaded
removeFile
close
findCategory
reload
removeLabel
createCategory
findFile
removeCategory            

Examine Project Properties

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

Open the airframe project and create a project object.

sldemo_slproject_airframe
proj = slproject.getCurrentProject
proj = 

  ProjectManager with properties:

          Name: 'Simulink Project Airframe Example'
    Categories: [1x2 slproject.Category]
         Files: [1x24 slproject.ProjectFile]
    RootFolder: [1x61 char]

Examine the project files.

files = proj.Files
files = 

  1x24 ProjectFile array with properties:

    Path
    Labels

Examine the labels of the eighth file.

proj.Files(8).Labels
ans = 

  Label with properties:

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

Get a particular file.

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

  ProjectFile with properties:

   Path:  'C:\Temp\airframe\models\AnalogControl.mdl'
    Labels: [1x1 slproject.Label]

Find out what you can do with the file.

methods(myfile)
Methods for class slproject.ProjectFile:

addLabel
removeLabel
findLabel

Output Arguments

expand all

proj — Projectproject object

Project, returned as a project object. Use the project object to manipulate the currently open Simulink Project at the command line.

Properties of proj output argument.

Project PropertyDescriptionValue
NameProject nameString
CategoriesCategories of project labelsCell array of strings
FilesPaths and labels of project filesCell array of strings
RootFolderFull path to project root folderString
ShortcutsShortcut files in projectCell array of strings

More About

expand all

Tips

Alternatively, you can use simulinkproject to get a project object, but simulinkproject also opens and gives focus to the Simulink Project Tool. Use simulinkproject to open projects and explore projects interactively. Use slproject.getProject for project automation scripts.

See Also

Functions

Was this topic helpful?