Documentation

slproject.getCurrentProjects

List all top-level万博1manbetx项目

Syntax

项目= slproject.getCurrentProjects

Description

example

项目= slproject.getCurrentProjectsreturns a list of all top-level projects open in Simulink®Project. Currently only one or zero top-level projects can be loaded. Returns an object array of 1 or 0ProjectManagerobjects项目that you can use to manipulate the project programmatically. Useslproject.getCurrentProjectsfor project automation scripts.

If you executeslproject.getCurrentProjectsinside a project shortcut, it returns only the project that the shortcut belongs to. If the shortcut belongs to a referenced project, it returns the referenced project.

Examples

collapse all

Open the Airframe project and useslproject.getCurrentProjectsto get a project object to manipulate the project at the command line.

sldemo_slproject_airframe项目= 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'

Open the airframe project and create a project object.

sldemo_slproject_airframe项目= slproject.getCurrentProject
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'

Find out what you can do with your project.

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.

Open the airframe project and create a project object.

sldemo_slproject_airframe项目= slproject.getCurrentProjects;

Examine the project files.

files = proj.Files
files = 1x30 ProjectFile array with properties: Path Labels Revision SourceControlStatus

Examine the labels of the eighth file.

proj.Files(8).Labels
ans = Label with properties: File: 'C:\Work\airframe\data\system_model.sldd' 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] Revision: '2' SourceControlStatus: Unmodified

Find out what you can do with the file.

methods(myfile)
Methods for class slproject.ProjectFile: addLabel removeLabel findLabel

Output Arguments

collapse all

Projects, returned as an object array of 1 or 0ProjectManagerobjects. Use the project object to manipulate the currently open Simulink Project at the command line.

Properties ofProjectManagerobjects in output argument.

Project Property Description
Name Project name
Categories Categories of project labels
Shortcuts Shortcut files in project
ProjectPath

Folders that the project puts on the MATLAB®path

ProjectReferences Folders that contain referenced projects
Files Paths and names of project files
RootFolder Full path to project root folder

Tips

Alternatively, you can usesimulinkprojectto get a project object, butsimulinkprojectalso opens and gives focus to the Simulink Project Tool. Usesimulinkprojectto open projects and explore projects interactively. Useslproject.getCurrentProjectsfor project automation scripts.

Introduced in R2016a

Was this topic helpful?