How to create shortcut by script

Hi,

I want to write a script that will populate a workspace with entity shortcuts based on certain entity properties.
Specifically I want to create a workspace for each of our tablespaces, then use a script to loop through the entities, examine the tablespace property and create a shortcut on the appropriate workspace. With about 650 entities I thought a script would be easier and less prone to error.
I can’t figure out how to create a shortcut.
Please can someone give me a code snippet.

Many thanks
Malcolm

Hi Malcolm,

Unfortunately, it’s not possible at the moment. However, I have great news - it will be possible in next Beta that should come out by the end of this week. My co-worker Daril already made the whole script for you. However, the script will be executable in the new Beta then.
So, as soon as the Beta is released, I’ll let you know and post the script here.

Thanks for your patience!

Regards,

Vladka + Daril

Great, thanks for that.
I’m afraid I’m only able to work on TDM in my “spare” time at the moment.
Regards
Malcolm

Hi Malcolm,

The Beta 3.2.2.22 is available now. Feel free to download it from:
http://modeling.inside.quest.com/ann.jspa?annID=150

In this Beta, you can run the attached script. Please check it out.

Instructions:

  1. Open the Scripting Window (Tools menu) and enter the code there.
  2. From the View menu, select 'Show Registered Objects'.
  3. From the 'Available Objects' window, select the model for which you like to run the code and click the arrow to move the model to the window 'Selected Objects'.
  4. In the script, the model is named Model. So, either modify the script for your model name or simply click your model in the 'Selected Objects' window | Name in Script column | press F2 and rename it 'Model'. - Please see the attached screenshot.
  5. Click the 'Execute Script' icon in the toolbar of the Scripting Window.

Result:
See the Model Explorer of your model. There should be new workspaces named by the tablespaces. Check out the workspaces. Please re-arrange the shortcuts of objects on the WS (the tables will be one on another.)

Malcolm, we hope this is what you need. If you have any questions or if the script does not meet your requirements, please do not hesitate to write us back. Thanks very much.

P.S. After your feedback, I'll publish the script to the Scripts section too.

Regards,

Vladka + TDM Team

Hi Malcolm,

The Beta 3.2.2.22 is available now. Feel free to download it from:
http://modeling.inside.quest.com/ann.jspa?annID=150

In this Beta, you can run the attached script. Please check it out.

Instructions:

  1. Open the Scripting Window (Tools menu) and enter the code there.
  2. From the View menu, select ‘Show Registered Objects’.
  3. From the ‘Available Objects’ window, select the model for which you like to run the code and click the arrow to move the model to the window ‘Selected Objects’.
  4. In the script, the model is named Model. So, either modify the script for your model name or simply click your model in the ‘Selected Objects’ window | Name in Script column | press F2 and rename it ‘Model’. - Please see the attached screenshot.
  5. Click the ‘Execute Script’ icon in the toolbar of the Scripting Window.

Result:
See the Model Explorer of your model. There should be new workspaces named by the tablespaces. Check out the workspaces. Please re-arrange the shortcuts of objects on the WS (the tables will be one on another.)

Malcolm, we hope this is what you need. If you have any questions or if the script does not meet your requirements, please do not hesitate to write us back. Thanks very much.

P.S. After your feedback, I’ll publish the script to the Scripts section too.

Regards,

Vladka + TDM Team
CreateWorkSpacesByTablespaces.zip (426 Bytes)

Hi Vladka,

I tried this in 3.2.3.9 beta, using one of our smaller models that had been created in oe of the earlier commercial releases by RE.

The script created the Workspaces but did not find any entities in the tablespaces (tbsp.entities.count = 0).
In the same model, I created a new TS and a new Entity using this new TS. The script correctly created a WS for the new TS and added the entity shortcut.

Regards
Malcolm

Hi Vladka,

I’ve tweaked the script to work with our models, see attached file.

Note: the Model Explorer does not fully update the WS shortcut lists until it is closed/reopened.

Regards
Malcolm
CreateWorkSpacesByTablespaces2.zip (475 Bytes)

Regards,

Vaclav

Hi Malcolm,

I am glad you managed to modify the script to be OK for your purposes. Our script will work on models created in version 3.2 BETA, not models created in earlier versions. In earlier versions of TDM, entities knew information about tablespaces, but tablespaces didn’t know information about entities. That was wrong and the problem was fixed in version 3.2 BETA.

Hi Vaclav,

I would expect that opening a model in a newer version of TDM should bring the model up to the latest format.
If it doesn’t we are likely to meet other problems later.

Regards
Malcolm

Hi Malcolm,

yes, you are right. Models opened in newer version should be corrected. We are working on some automation, for now, there is option Repair Model (Right click your model in Model explorer or Application View and select Repair Model - Note: Expert Mode must be enabled via Settings | Options, on tab General.).

CR number for the automatic model repair is 51602.

Try to run Model repair on your model and then execute the first script. It should work (I tested it on one of my older models and it worked OK.).

Thanks for your feedback!

Vaclav

Hi Vaclav,

I’ve just tried a repair first. I still get nothing in the WSs. (The TS Entity count is still 0).

Regards
Malcolm

Hi Malcolm,

can you send me the model to modeling@quest.com please? It may help us to improve the Repair functionality. Thanks!

Vaclav

Hi Vaclav,

I need to get approval for this. Please see PM.

Regards
Malcolm

Thanks for info in this thread. However, I want to go a bit more deep into adding shortcuts. I want to create workspace with some small part of my database – I want to have all Entities whose names begin with “sec”. This is pretty easy. I want also to have all relations between them in my workspace. So the rule is: if entity’s name begins with “sec” – it counts; relation counts only if connecting two “sec” entities.

I have created script (Care is the name of the model), but I do not know how to add relation shortcut to workspace…

Regards,

Michal
newWS.txt (1.05 KB)

WS.CreateWorkspaceLineByParentobject(Rel, 2504);

If you have any questions, please write us back. Thanks.

Regards,

Vladka + Mario

Hi Michal,

Please replace this line of your script (last line):
WS.NewWorkSpaceLine( 2504, Rel);

with this new one:

Thanks, that’s it!

Michal

Uhm... not exactly :frowning: I do not see relationships' captions... If I create new relation in my new workspace, caption will be visible. But for shortcuted relationships this does not work... See the attached image...

Regards
Michal

WLine = WS.CreateWorkspaceLineByParentobject(Rel, 2504);

if (WLine != null)

WLine.FontSize = 10;

Thanks very much!

Regards,

Vladka + Mario

Hello Michal,

Thanks for your notification! There is a problem with font size. We will verify it.
For now, you can modify it via script. See below a part of the code how you can do it:

Quick update - the problem description: During calling CreateWorkspaceLineByParentobject, the initialization of line does not pass.
We will fix it.
CR # 56 957.

Michal, thanks again!

Regards,

Vladka