Peer-to-Peer Forum

 

Login Register    
Scripting Capabilities
Posted: 23 March 2009 09:33 AM  
Sr. Member
RankRankRankRank
Total Posts:  550
Joined  2009-03-17

I appreciate the fact that we are now getting a robust capability for WRITING scripts, but as an end-user who has to deal with a half dozen other scripting languages already, what I would REALLY like to see is the reconsititution at some level of the basic “scripting” capability that existed in 1994, which is that your hit “record”, performed some functions, and hit “Stop”. then you save that set of functions and could apply it to a set of OpenFlight models.
For newer users, what I would love to see, and please chime in with agreeance to help motivate Presagis, is something similar to PhotoShop’s Action Routines, where you record a parameterized set of actions and the run them on a set of files.  Now that the backbone of the scripting is in place, hopefully this should be a fairly simple leap, since the record function could basically srite the script as you go along.

 
Posted: 24 March 2009 06:24 PM   [ # 1 ]  
Moderator
RankRankRankRank
Total Posts:  386
Joined  2008-07-03

We would really like to see this functionality as well. We have designed the OpenFlight API scripting as a first step in this direction. However, as kent pointed out, we can’t take any further steps in this direction without your help. If you would like to see this functionality in future versions of Creator, then please let us know. This forum is a great place to do exactly that.

Just so we can communicate clearly, we have identified three levels of scripting that could be added to creator. These levels each build upon the previous level(s).

OpenFlight API Scripting
This is what we have already implemented. It is the first step toward the other two levels of scripting, but is very useful by itself.

Creator Scripting
This extends OpenFlight API Scripting by allowing users to call Creator’s tools via scripts. The tools would only be callable inside of the Creator environment on the current database. This will allow users to really leverage the vast number of tools and features of Creator.

Record/Playback Scripts/Actions.
The last logical step is to record some sequence of actions and create a Creator Script/OpenFlight API Script that reproduces those actions. This then would be available to apply to a set of models to significantly streamline many workflows.


Everyone who is interested in these features please let us know. Be advised however, that you should only vote that you want these features if they would really help your work flow. Adding features as significant as these will definately delay other features you may find more helpful.  Also to make sure we understand your needs as completely as possible, please provide a brief use case that you envision this new functionality helping you with. It may be that there is already a better way, or an acceptable way to accomplish the same thing. Or it may be that we never envisioned a use case like you described and it will help us to deliver the best possible solution for your needs.

Thanks, and I look forward to reading your use cases.

Chris R.

 
Posted: 25 March 2009 08:15 AM   [ # 2 ]  
Sr. Member
RankRankRankRank
Total Posts:  550
Joined  2009-03-17

yes - I see that this topic has 30 views.  I for one understand that the only way to get new capabilities implemented is to communicate to Presagis the importance of these capabilities.  people - chime in even if only to say “Yes, I’d like to see that!”

Chris - this is a very good approach, exactly the way I would go about it if I were the Tool Man.  The one thing I might do is make the middle stage either a two phase process, or make it a little more capable by allowing you to run on a set of files as opposed to having to open a file, run the script, open a file, run the script ....  Another nice to have either in the more mature phase or in the IOC would be maybe a pull down menu of functions (like Excel’s formula builder) that you can either drag into the script, or at least reference quickly without the overhead of a full LRM or help guide.  I’m assuming that you wuold be opening a sub-window to write the script into ....

 
Posted: 25 March 2009 08:25 AM   [ # 3 ]  
Jr. Member
RankRank
Total Posts:  44
Joined  2007-11-26

ill second it

 
Posted: 25 March 2009 01:59 PM   [ # 4 ]  
Newbie
Rank
Total Posts:  17
Joined  2008-06-12

I also vote for the addition of the scripting capabilities described by Chris Rogers here.

Signature 

Bernard Leclerc, Eng.
Technical Specialist, Database Technologies
Simulation Products and Military Training & Services
CAE

8585 Côte-de-Liesse
Saint-Laurent (Québec)
Canada H4T 1G6
Tél +1-514-341-2000 poste 2062
Fax +1-514-341-7699

 
Posted: 31 March 2009 02:08 PM   [ # 5 ]  
Sr. Member
RankRankRankRank
Total Posts:  118
Joined  2008-07-28

I’m on this bandwagon too, even though I have not broken into the current capabilities in 3.5.  I too would like the ability to run scripted commands over file sets, as opposed to getting creator to perform tool operations via scripting.

In fact, my vote is to see the existing API scripts working external to creator first (shocking I know).  Maybe that’s not possible from an engineering standpoint, but that’s my onion - er, opinion!

 
Posted: 31 March 2009 03:18 PM   [ # 6 ]  
Moderator
RankRankRankRank
Total Posts:  386
Joined  2008-07-03

The current version of is already capable of stand alone scripting, and of accessing multiple files to perform batch operations.  What we would add in the last level of scripting would be the ability to do all of that with minimal interaction with script code.

FYI:
Here is a script I wrote for another forum post before the update to the new forum. It shows how to accomplish a similar task to attribute search on a set of files, with more control on how you test for a match.  Just paste this code into the script window in creator and modify the Prefunc section to suit your needs. Right now it scales all switch in and switch out distances in half, for all flt files in the directory you specify.

import osglob

def Prefunc 
(dbparentrecdata):
    
type mgGetCode(rec)
    if (
type == fltLod):
        
outs mgGetAttList (recfltLodSwitchInfltLodSwitchOut )
        if (
outs[1]):
            
switchin  outs[1] 0.5
            switchout 
outs[2] 0.5
            mgSetAttList 
recfltLodSwitchInswitchinfltLodSwitchOutswitchout )
    return 
MG_TRUE


status
folder mgPromptDialogFolder (None"Select Directory to Process"None)
for 
filename in glob.globos.path.join(folder'*.flt') ):
    
db mgOpenDb (filename)
    print 
"Processing "filename
    mgWalk 
(dbPrefuncNoneNoneMWALK_ON)
    
mgWriteDb (db)
    
mgCloseDb (db)


print 
"Finished Processing Directory" 
 
Posted: 31 March 2009 05:04 PM   [ # 7 ]  
Sr. Member
RankRankRankRank
Total Posts:  118
Joined  2008-07-28

Very cool Chris.. thanks!!!

 
Posted: 14 April 2009 03:43 PM   [ # 8 ]  
Jr. Member
RankRank
Total Posts:  31
Joined  2008-12-08

I tried running the script posted earlier in this thread (the one from last July that changes LOD ranges).  I got an error saying that mgPromptDialogFolder is not defined.  I tried adding a line to ” import * from mgapilib”.  This results in an error: “No module named mgaiplib”.  I tried copying mgapilib.py to my working directory, to no avail.  I tried running from both a Windows cmd and a cygwin window.  What am I missing?

 
Posted: 14 April 2009 04:52 PM   [ # 9 ]  
Moderator
RankRankRankRank
Total Posts:  386
Joined  2008-07-03

That function is API Access Level 4 so unfortunately it only functions inside of Creator. The script will only work as written in the Creator Script Editor. All of the OpenFlight Script commands still conform to the restrictions and Access Levels from the OpenFlight API. You can look at a functions Access Level in the OpenFlight API help.

Never fear however, you can replace this function with some UI toolkit’s file request dialog. There are several UI toolkits that work with python. Two popular options are Tinker and wxPython.

 
Posted: 17 April 2009 10:12 AM   [ # 10 ]  
Jr. Member
RankRank
Total Posts:  31
Joined  2008-12-08

Can scripts only be launched from within Creator?  I modified the aforementioned script to replace the directory prompt with a command line argument.  When I run it from a cygwin command line it can’t find msvcr80.dll.  I put that where it could be found, but the script does not load it properly.

 
Posted: 20 April 2009 12:23 PM   [ # 11 ]  
Moderator
RankRankRankRank
Total Posts:  386
Joined  2008-07-03

Scripts that only use API Level 1 and 2 can be ran standalone provided you set up your own python environment. Creator comes with its own python environment set up already for you, so it is the easiest way to get started, and it allows you to run all OpenFlight script commands regardless of API Level.  If you search the OpenFlight API’s help for OpenFlight Script you can find some instructions to set up your stand alone python environment.

However from your post, it looks like your runtime dll is not being found. This is likely related to a bug that was fixed in the 4.0 release. However this bug did not affect the OpenFlight API vc6 install. Until 4.0 comes out, I would try the vc6 version of the API and see if it solves the problem.

 
Posted: 27 April 2009 04:41 PM   [ # 12 ]  
Moderator
RankRankRankRank
Total Posts:  603
Joined  2008-07-02
dbdave - 17 April 2009 10:12 AM

Can scripts only be launched from within Creator?  I modified the aforementioned script to replace the directory prompt with a command line argument.  When I run it from a cygwin command line it can’t find msvcr80.dll.  I put that where it could be found, but the script does not load it properly.

dbdave,

As Chris noted in his post, this has been fixed in the VC8 version of the API distribution in our upcoming release.  It has also been corrected in a version 3.5.2 patch for VC8.  If you need this patch (it’s not generally available on our website) contact customer support.  They can provide it to you.

 
Posted: 27 April 2009 05:59 PM   [ # 13 ]  
Moderator
RankRankRankRank
Total Posts:  603
Joined  2008-07-02
KentNichols - 25 March 2009 08:15 AM

snip… Another nice to have either in the more mature phase or in the IOC would be maybe a pull down menu of functions (like Excel’s formula builder) that you can either drag into the script, or at least reference quickly without the overhead of a full LRM or help guide.  I’m assuming that you wuold be opening a sub-window to write the script into ....

Kent,
The existing script editor in Creator 3.5 does have this kind of thing built in.  It has “autocomplete” capability so as you type API function names, it lists (and lets you pick from) all those that match the letters you have typed so far.  To get a complete list, simply type mg (as all functions start with these 2 letters).  Then, after you select a function name, it lists the required parameters you need to supply for that function. 

Finally, if you do have the OpenFlight API SDK installed, it provides context sensitive help links to the functions you are calling (links directly into the OpenFlight API docs, that is).