136715149
MD2024x
3
Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Use the com.nomagic.uml2.impl.ElementsFactory ElementsFactory class for creating model elements. To create a model element, a session with the com.nomagic.magicdraw.openapi.uml.SessionManager must be created.
The create<model element type>Instance() method creates a new model element instance. The figure above shows only a subset of all available create<...>Instance() methods.
All changes in the UML model will be registered and, on the session closing, will be added into the command history.
Code Block | ||
---|---|---|
| ||
Project project =...; ElementsFactory f = project.getElementsFactory(); SessionManager.getInstance().createSession(project, "Create a package"); Package packageA = f.createPackageInstance(); //add created package into a root of the project packageA.setOwner(project.getPrimaryModel()); ... // apply changes and add a command into the command history. SessionManager.getInstance().closeSession(project); |
Info |
---|
You can find the code examples in <modeling tool installation directory>\openapi\examples\accessors |