Phillip Martin wrote: > > > -----Original Message----- > > From: aztec-users-bounce@xxxxxxxxxxxxx > > [mailto:aztec-users-bounce@xxxxxxxxxxxxx]On Behalf Of Dominique Boutin > > Sent: Tuesday, 9 July 2002 7:41 AM > > To: aztec-users@xxxxxxxxxxxxx > > Subject: [aztec-users] js > > > > > > > > I looked again a bit into the js thing, but I did not come very far. > > > > Jordan wrote some time ago: > > --- > > 1. just write your own js function, > > 2. give it a name, > > 3. edit the key config file to use that command, > > 4. and there you go! > > ---- > > > > Is there a mechanism that loads/runs/evaluates scripts from a certain > > directory at startup? > > No, unfortunately there isn't. Just one of those things I keep putting off. There is a default directory that Aztec will look in for scripts when you explicitly load them (the /script directory), but no code for doign an auto load. Probably no more than 10-20 lines of code to do the job. > > > How do I have to manipulate the cfg file, in order to have keys calling js > > functions? (a GUI for that would be great !!!) > > Again, this can't be done at the moment. > > I think I will whack in a simple mechanism for loading scripts on startup, > and for executing scripts as well. It may not be the perfect way to do it, > but at least there will be something there. > > > Script Console: > > It would be cool being able to recall/reprint the last command (even if it > > did not work) ... with crtl+arrowUp or something. > > Aye, I think there needs to be a more sophisticated script editor as well. I agree. Problem is that writing text editors isn't my forte. I put together a very simple variant of a windows edit box to make a command window. If I find some nice code laying around for a console window, I'll happily replace what I did with something better. Suggestions? > > > > > Commands: > > How can I have acces to all scene objects? couldn't find something like: > > Scene.allObjects > > or Scene.selecetAll There are a couple of ways to do what you want. First (and probably least useful) is an undocumented function, "stats(...)". You can dump every symbol in the interpreter with: js> stats('atom') all the global ones with: js> stats('global') Look at all the methods of an object (the global Scene object is used in the example) with: js> stats('Scene') If you want to see what object are in the scene, you can simply show all of its properties (shown after creating a cube primitive): js> for (x in Scene) print(x) WhiteLightShape whiteLight backLightShape backLight TimeSegment01 CubeShape Cube1 Phil has some nice examples below to show other things you can do with the Scene object. Also, you can refer to the script docs in the docs/htdocs/webpage directory. [File is script-api.html] That is a relatively complete description of what has been implemented to date. Note that it doesn't document writing JavaScript - you can find tons of resources for that on the web (and better written that I'm going to be able to do). The docs are for the Aztec specific classes. Note that adding the LiveConnect classes (to allow running real Java from JavaScript) is easy and works well. It is not currently enabled (mostly because I'm not really sure what sort of JRE people might or might not have installed). If there is a real desire for this, I can get it plugged in (with extra work it could be an configurable option). > > How can I get the name of an object - or how can i select an > > object by name? > > First here is a little handy function from common/scripts/test.js: > > function showParams(obj) { > for (x in obj) > print(x + ": " + obj[x]); > } > > It will come in very handy. > > ------ > > To select an object do this: > > Scene.selectObject('objectname'); > or > Scene.selectObject(actualJavaScriptAztecObject); > > ------ > > This is is very non obvious, to select all objects, do this: > Scene.KEditSelectAll(); > > Note the very horrid name of it. This is the same name of the function that > is bound to a keypress when you customise your keys. > > ------ > > Here is an example of getting all the selected objects in a scene: > > function printSelectedObjects() { > selObjs = Scene.getSelectedObjectList(); > > for (x in selObjs) { > print('Object ' + selObjs[x].Name + ':\n'); > showParams(selObjs[x]); > } > } > > ------