How to automate the PSD load data improved fit?

Member, Moderator, Employee Posts: 870
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭

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

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • Member, Moderator, Employee Posts: 870
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    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.

    1. # Activate "improved fit"
    2. PSGAcceleration=str(BaseExcitation.Name)
    3. cmd1="""
    4. ds=DS;
    5. wb=WB;
    6. var oScript = DS.Script;
    7. var ListView=DS.Script.lv;
    8. var sm = DS.SelectionManager;
    9. var model = DS.Tree.FirstActiveModel;
    10. var myenvironments = model.Environments;
    11. var myEnv = myenvironments.Item(2);
    12. DSSelectTreeItem("""
    13.  
    14. cmd3=""");
    15. var Load = ds.Tree.FirstActiveObject;
    16. ListView.SelectItem("Load Data");
    17. DS.Script.doImprovedPSDLoadFit();
    18. // Find and Select a Branch by the "name" in the Tree
    19. // node = "name"
    20. function DSSelectTreeItem( node ) {
    21. if ( typeof(node) == "string" ) {
    22. var index = DSfindTreeNode( node );
    23. // Start from top of tree if first search fails.
    24. if ( index == 0 ) {
    25. oScript.tv.SelectedItem = oScript.tv.Nodes(1);
    26. index = DSfindTreeNode( node );
    27. }
    28. if ( index != 0 ) {
    29. oScript.tv.SelectedItem = oScript.tv.Nodes(index);
    30. }
    31. }
    32. }
    33. function DSfindTreeNode( name ) {
    34. var nameLower = name.toLowerCase();
    35. var oNode = oScript.tv.SelectedItem;
    36. var textLower = oNode.Text.toLowerCase();
    37. while( oNode != null && nameLower != textLower ) {
    38. oNode = oScript.GetNextItem( oNode );
    39. if( oNode ) textLower = oNode.Text.toLowerCase();
    40. }
    41. var index = 0;
    42. if( oNode != null ) {
    43. var nNodes = oScript.tv.Nodes.Count;
    44. for ( index = 1; index <= nNodes; index++ ) {
    45. if ( oScript.tv.Nodes(index) == oNode ) break;
    46. }
    47. if ( index > nNodes ) index = 0;
    48. }
    49. return index;
    50. }
    51. """
    52. cmd=cmd1+"\""+PSGAcceleration+"\""+cmd3
    53. ExtAPI.Application.ScriptByName('jscript').ExecuteCommand(cmd)
  • Member, Employee Posts: 2
    First Anniversary Name Dropper First Comment
    ✭✭✭
    edited February 2024

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

    Spoiler
    1. def doImprovedFit():
    2. cmd = '''
    3. DS.Script.lv.SelectItem("Load Data");
    4. DS.Script.doImprovedPSDLoadFit();
    5. '''
    6. ExtAPI.Application.ScriptByName('jscript').ExecuteCommand(cmd)
    7.  
    8. type= DataModelObjectCategory.PSDLoad
    9. PSDs = DataModel.GetObjectsByType(type)
    10. nPSD = PSDs.Count
    11.  
    12. for i in range(nPSD):
    13. PSDs[i].Activate()
    14. doImprovedFit()
  • Member, Employee Posts: 2
    First Anniversary Name Dropper First Comment
    ✭✭✭
    edited February 2024

    Hi,

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

    1. def doImprovedFit():
    2. cmd = '''
    3. DS.Script.lv.SelectItem("Load Data");
    4. DS.Script.doImprovedPSDLoadFit();
    5. '''
    6. ExtAPI.Application.ScriptByName('jscript').ExecuteCommand(cmd)
    7.  
    8. type= DataModelObjectCategory.PSDLoad
    9. PSDs = DataModel.GetObjectsByType(type)
    10. nPSD = PSDs.Count
    11.  
    12. for i in range(nPSD):
    13. PSDs[i].Activate()
    14. doImprovedFit()

Welcome!

It looks like you're new here. Sign in or register to get started.