How to automate the PSD load data improved fit?

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 864
500 Comments Photogenic Name Dropper Solution Developer Community of Practice Member
✭✭✭✭

How to automate the "improve fit" option for a PSD signal?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 864
    500 Comments Photogenic Name Dropper Solution Developer Community of Practice Member
    ✭✭✭✭

    Last time I checked, there was no supported API to do this. There is a workaround that uses unsupported commands - no guarantee that it will work, and use at your own risk.

    # Activate "improved fit"
    PSGAcceleration=str(BaseExcitation.Name)
    cmd1="""
    ds=DS;
    wb=WB;
    var oScript = DS.Script;
    var ListView=DS.Script.lv;
    var sm = DS.SelectionManager;
    var model = DS.Tree.FirstActiveModel;
    var myenvironments = model.Environments;
    var myEnv = myenvironments.Item(2);
    DSSelectTreeItem("""
    
    cmd3=""");
    var Load = ds.Tree.FirstActiveObject;
    ListView.SelectItem("Load Data");
    DS.Script.doImprovedPSDLoadFit();
    // Find and Select a Branch by the "name" in the Tree
    // node = "name"
    function DSSelectTreeItem( node ) {
        if ( typeof(node) == "string" ) {
        var index = DSfindTreeNode( node );
        // Start from top of tree if first search fails.
        if ( index == 0 ) {
            oScript.tv.SelectedItem = oScript.tv.Nodes(1);
            index = DSfindTreeNode( node );
        }
        if ( index != 0 ) {
            oScript.tv.SelectedItem = oScript.tv.Nodes(index);
        }
        }
    }
    function DSfindTreeNode( name ) {
        var nameLower = name.toLowerCase();
        var oNode = oScript.tv.SelectedItem;
        var textLower = oNode.Text.toLowerCase();
        while( oNode != null && nameLower != textLower ) {
        oNode = oScript.GetNextItem( oNode );
        if( oNode ) textLower = oNode.Text.toLowerCase();
        }
        var index = 0;
        if( oNode != null ) {
        var nNodes = oScript.tv.Nodes.Count;
        for ( index = 1; index <= nNodes; index++ ) {
            if ( oScript.tv.Nodes(index) == oNode ) break;
        }
        if ( index > nNodes ) index = 0;
        }
        return index;
    }
    """
    cmd=cmd1+"\""+PSGAcceleration+"\""+cmd3
    ExtAPI.Application.ScriptByName('jscript').ExecuteCommand(cmd)
    
  • Debanjan Debnath
    Debanjan Debnath Member, Employee Posts: 2
    First Comment Name Dropper
    ✭✭✭
    edited February 18

    Hi @Pernelle Marone-Hitz,
    I have the following script that might be useful to fit all the PSDs.

    def doImprovedFit():
        cmd = '''
            DS.Script.lv.SelectItem("Load Data");
            DS.Script.doImprovedPSDLoadFit();
        '''
        ExtAPI.Application.ScriptByName('jscript').ExecuteCommand(cmd)
    
    type= DataModelObjectCategory.PSDLoad
    PSDs = DataModel.GetObjectsByType(type)
    nPSD = PSDs.Count
    
    for i in range(nPSD):
        PSDs[i].Activate()
        doImprovedFit()
    
  • Debanjan Debnath
    Debanjan Debnath Member, Employee Posts: 2
    First Comment Name Dropper
    ✭✭✭
    edited February 18

    Hi,

    I've the following script which might be useful to improve fit all the PSDs.

    def doImprovedFit():
        cmd = '''
            DS.Script.lv.SelectItem("Load Data");
            DS.Script.doImprovedPSDLoadFit();
        '''
        ExtAPI.Application.ScriptByName('jscript').ExecuteCommand(cmd)
    
    type= DataModelObjectCategory.PSDLoad
    PSDs = DataModel.GetObjectsByType(type)
    nPSD = PSDs.Count
    
    for i in range(nPSD):
        PSDs[i].Activate()
        doImprovedFit()