Required knowledge: ÃÂ ÃÂ ÃÂ * How to trigger a script in EMTP
* What are DWDevice, DWCircuit, DWSignal, DWPin, etc in EMTP JavaScript?
This script gets a DWDevice from an EMTP DWCircuit.
This script gets DEV1 in the main circuit, then gets all resistances inside the subcircuit of DEV1
//** Get the current (active) DWCircuit object. See Help & Support/4 - JavaScript based Scripting in EMTP/DWCircuit for methods and attributes
var cCt = currentCircuit();
//** Get all devices of the DWCircuit cCt into an array whose names are DEV1.
var DWDevice_DEV1_array = cCt.devices('Name', 'DEV1');  //See Help & Support/4 - JavaScript based Scripting in EMTP/DWCircuit for more filtering options
                                                        //DWDevice_DEV1_array is an array with one element, because only one device is named DEV1 in cCt.Â
//Check if DEV1 was found
if(DWDevice_DEV1_array==null || DWDevice_DEV1_array.length==0){
    alert('The searched device does not exist!');
    halt();  //Stop the script. See Help & Support/4 - JavaScript based Scripting in EMTP/SPScript
}
//** Get DEV1 out of DWDevice_DEV1_array
var DWDevice_DEV1  = DWDevice_DEV1_array[0]             //DWDevice_DEV1 is the DWDevice of the first element (and only one) of DWDevice_DEV1_array
alert(DWDevice_DEV1 + ' is defined.')                   //alert, just for the exercises
   Â
//** Get DEV1 subcircuit
var DWCircuit_DEV1_subCct = DWDevice_DEV1.subCircuit()  //See subCirctuit method in Help & Support/4 - JavaScript based Scripting in EMTP/DWDevice
//** Get all resistances in the DWCircuit DWCircuit_DEV1_subCct into an array.
//The search is done using the LibType attribute (right click on a DWDevice/Attributes to see all attributes)Â
//LibType is a DWDevice attribute which corresponds to the name appearing in the library (see RLC Branches library).
//The libType of resistance is RLC: R
var resistanceDevs_array  = DWCircuit_DEV1_subCct.devices('LibType', 'RLC: R');     //See Help & Support/4 - JavaScript based Scripting in EMTP/DWCircuit for more filtering options
                                                                                    //resistanceDevs_array  is an array with one element, because only one device has a libType of 'RLC: R'.Â
alert('The resistances in '+ DWDevice_DEV1 + ' are: ' + resistanceDevs_array ) //alert, just for the exercises
Example folder: Click here