|
Rank: Newbie
Joined: 11/14/2016 Posts: 5 Location: South Africa
|
Using UModel Enterprise 2016 x64 sp1.
Is there any way I can programmatically (using C# with UModelLib and UModelPluginLib API's) copy and paste or move a package from one parent node to another, emulating the UI function doing this in the Model Tree View?
'Include Subproject' does not work for me as it maintains the tree structure of the included subproject. I require to move/copy an entire branch to lower branch in the model tree.
|
|
Rank: Advanced Member
Joined: 9/28/2005 Posts: 371 Location: Vienna
|
Hi WillemF,
Currently there is no built in "move" functionality, but you can iterate and move the elements by yourself. Of course, this is not very convenient if you have many different element kinds, so we will put this on our feature list!
|
|
Rank: Newbie
Joined: 11/14/2016 Posts: 5 Location: South Africa
|
Got this working using a keyboard input simulator library. I used the open source package: Windows Input Simulator (C# SendInput wrapper) which is on GitHub, and NuGet. This worked for me because the 'Copy from' and 'Paste to' packages are fixed at the same location in the Model Treeview everytime.
Code:// Select the package. UModel.ActiveDocument.FocusUMLDataInModelTree(package, true, true); // Copy the package. // Keyboard is the default 'IKeyboardSimulator' interface implementer. Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C); // Select paste-to package. // Navigate up. Input.Keyboard.KeyPress(VirtualKeyCode.UP); ... // etc. // Navigate right. Input.Keyboard.KeyPress(VirtualKeyCode.RIGHT); ... // etc. // Paste the package. Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V);
I also found that you could pass over some dialog boxes by simulating keystrokes prior to the UModelLib operation that pops up the dialog box. It may also work work using 'System.Windows.Forms.SendKeys', but have not tried.
It's a heck-of-a kludge, but currently works fine for me. Would be great though if a formal API exists to move and copy-paste packages.
|
|
guest |