Thanks - I really must remember to switch my brain on more often!
Also I need to remind myself that with modern code you start at the bottom and work up (I still tend to write code in a very dated monolithic inline way, only very occasionally pulling chunks out into seperate functions). I completely missed this bit at the bottom of your code:
Here I go, I only hope not to confuse you more, but code looks weird cause it is compiled code, intended to be consumed as regular DAZ objects. Project has 3 main classes:
// Class to send debug messages to console / log file.declare class Logger { static INFO: string; static WARN: string; static ERROR: string; lines: string[]; // clear messages list clear(): void; // outputs an informational debug message info(fmt: string, ...args: any[]): void; // outputs a warning debug message warn(fmt: string, ...args: any[]): void; // outputs an error debug message error(fmt: string, ...args: any[]): void; write(type: string, fmt: string, args: any[]): void; // gets the string representation of message list toString(): string;}// Class to expose implementation details out of DAZ Objectsdeclare class Reflector { name: QString; properties: PropertyInfo[]; methods: MethodInfo[]; ancestorName: QString; constructor(); initialize(): void; // Set instance object to reflect setObject(o: any): Reflector; addProperty(o: any, name: string): void; addMethod(o: any, name: string): void; // Gives string representation of current object toString(): string;}// creates reflector application declare class DazReflectorApplication extends ApplicationBase { pixmapLabel: DzLabel; constructor(appName?: string); initialize(): void;}// global variablesdeclare var logger: Logger;declare var reflector: Reflector;var app = new DazReflectorApplication("Any app name");var nodeCount = Scene.getNumNodes();var nodeList = Scene.getNodeList();nodeList.forEach(function(n){ if(n.className() == "DzFigure") { logger.info(reflector.setObject(n).toString()); logger.info(" name: %1", n.name); logger.info(" class: %1", n.className()); logger.info("assetUri: %1", n.assetUri); }});app.run();
Last part of the code is very simple as it creates an application instance, which is a dialog with two Tab objects, one of them serves as a console message. then, we get the node list from the Scene and test each node to be a valid DzFigure before getting the file location(assetUri).
The idea to share all this code is to help others to use it as a base to dig the inner details of scripting objects.
@3dcheapskate, the intent of the code is to have an easy way to know what methods and properties are on any given object in DAZ Script. Think of it as an API generator. Example usage code:
// in place of the "main" code at the end of the file, starting with// var app = .../**Prints out information for the specified oObject*/function printObjectDetails(oObject) { var oReflector = new Reflector(); oReflector.setObject(oObject); print(oReflector.toString());}// new "main" codevar oDialog = new DzDialog(); // example object, this could be anything you're curious aboutprintObjectDetails(oDialog);
Comments
ok. Apology accepted.
Thanks - I really must remember to switch my brain on more often!
Also I need to remind myself that with modern code you start at the bottom and work up (I still tend to write code in a very dated monolithic inline way, only very occasionally pulling chunks out into seperate functions). I completely missed this bit at the bottom of your code:
Original comment edited a second time - when I say something foolish I'm happy to admit it!
What is it suppose to do ?
jag11 indicated that his code presents a dialog and lets you get the full path of a figure along with properties and methods of objects.
I'd guess that it's logging the name, className and assetUri for every figure in the scene and displaying them all in a dialog.
But it needs somebody who understands OO (i.e. not me! ;o) ) to explain the details. Anybody ?
Here I go, I only hope not to confuse you more, but code looks weird cause it is compiled code, intended to be consumed as regular DAZ objects. Project has 3 main classes:
Last part of the code is very simple as it creates an application instance, which is a dialog with two Tab objects, one of them serves as a console message. then, we get the node list from the Scene and test each node to be a valid DzFigure before getting the file location(assetUri).
The idea to share all this code is to help others to use it as a base to dig the inner details of scripting objects.
@3dcheapskate, the intent of the code is to have an easy way to know what methods and properties are on any given object in DAZ Script. Think of it as an API generator. Example usage code:
Creates output that looks like the following:
So then you can think "Oh,
DzDialog
has a property calledcaption
! Now I can code with confidence!"Ah! Now that is useful, what with all the holes in the documentation... :)
Thanks jag11 and djigneo