Hi all,
ich have the problem that i wrote an report which reads all objects of my prozessmodell but ist dosent sort and filter and i don´t know what to do.
In detail: I have an prozessmodell and i only need the "Function" objects for my report and have to sort them subject to the Y-position.
Could somebody help me?
Here is my Code which reads the Objects.
function objects(){
aObjDefs = oModel.ObjDefList();
var sObjName;
for (var j = 0; j < aObjDefs.length; j++) {
var oObjDef = aObjDefs[j];
sObjName = oObjDef.Name(nLocale);
// if(oObjDef.AttrType == "Function"){
oOutput.TableRow();
oOutput.TableCell("Call " + sObjName, 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0);
// }
}
}
Hi Klien,
You can write your script for Object Occurrences instead of Object def and then sort my geometry.
Below post might help you:
http://www.ariscommunity.com/users/deeptilad/2012-11-27-how-sort-order-objects-aris-script-report
Regards,
D
Hallo Ms. Deepti Lad,
thank you for your answere.
I tryed as you said, but it didn´t work.
One point i finished.
I could now sort out all objects, which are no "Functions".
My new Code is:
var nLocale=Context.getSelectedLanguage();
var oOutput = Context.createOutputObject();
var aModels = ArisData.getSelectedModels();
var oModel;
var aObjDefs = ArisData.getSelectedObjDefs();;
function objects(){
aObjDefs = oModel.ObjDefList();
var sObjName;
var type
for (var j = 0; j < aObjDefs.length; j++) {
var oObjDef = aObjDefs[j];
sObjName = oObjDef.Name(nLocale);
type = oObjDef.Type();
if(type == "Function"){
oOutput.TableRow();
oOutput.TableCell("Call " + sObjName, 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0);
oOutput.TableCell("", 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0);
}
}
}
function main(){
objects()
oOutput.WriteReport();
}
main()
The only thing I need ist now to sort the "Functions" I get.
I know that it is "aObjDefs = ArisData.sort(aObjDefs, Constants.SORT_Y, nLocale);" but it doesn´t work.
Could somebody tell me why?
Regards
Klein
Hello Klein,
to sort your objects with the y-position criterium, you have to use the occurences and not the definitions. Because only the occurences have the property "y-position".
e.g.
Instead of using
var aObjDefs = oModel.ObjDefList();
use:
var aObjOccs = oModel.ObjOccList();
To sort:
aSortedObjOccs = ArisData.sort(aObjOccs, Constants.SORT_Y, nLocale);
BTW:
To check if a object definition is a function use the object type number e.g.
if( objDef.TypeNum() == Constants.OT_FUNC ) { //do somthing with the function object }
Regards,
Jens
Hello Heylmann,
thank you very much for your help.
This is my solution:
function objects(){
aObjOcc = oModel.ObjOccList();
var aSortedObjOcc = ArisData.sort(aObjOcc, Constants.SORT_Y, Constants.SORT_X, nLocale);
for (var j = 0; j < aSortedObjOcc.length; j++) {
var oObjDef = aSortedObjOcc[j];
if(oObjDef.ObjDef ().Type() == "Function"){
oOutput.TableRow();
oOutput.TableCell("Call " + oObjDef.ObjDef().Name(nLocale), 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0);
oOutput.TableCell("", 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0);
}
}
}
Hi Klein,
Alternatively you can write your code as below.
function objects(){
aObjOcc = oModel.ObjOccListFilter(Constants.OT_FUNC);
var aSortedObjOcc = ArisData.sort(aObjOcc, Constants.SORT_Y, Constants.SORT_X, nLocale);
// var aSortedObjOcc = ArisData.sort(aObjOcc, Constants.SORT_GEOMETRIC, nLocale);
for (var j = 0; j < aSortedObjOcc.length; j++) {
var oObjDef = aSortedObjOcc[j];
oOutput.TableRow();
oOutput.TableCell("Call " + oObjDef.ObjDef().Name(nLocale), 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0);
oOutput.TableCell("", 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0);
}
}
By using 'ObjOccListFilter' you can specify the typenumber of the Function object and you will have the list of Function objects only and hence you can omit the check if the object type is 'Function'.
Also, for sorting you can use Geometric sort, as specified on the commented line in the above code snippet.
Regards
Rahul