IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Copy/paste or move package programmatically Options · View
WillemF
Posted: Monday, November 14, 2016 8:35:04 AM
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.
cor
Posted: Tuesday, November 15, 2016 7:06:21 AM
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!
WillemF
Posted: Friday, November 18, 2016 9:03:04 AM
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.
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.