Is it possible to modify this script to make same width or height objects?

I found this script that makes the objects selected from the same width AND height. I am very new to scripting. is it possible to change this to an object of the same width, leaving their heights the same?

mySelection = activeDocument.selection;

If (mySelection.length > 0) {}

If {(mySelection instanceof Array)

goal = mySelection [mySelection.length - 1];

for (i = 0; i <(mySelection.length-1); i ++) {}

ratioW = 100/(mySelection[i].width/goal.width);

ratioH = 100/(mySelection[i].height/goal.height);

mySelection [i] .resize (ratioW, ratioH)

}

}

} else {}

Alert ("nothing selected!")

}

Thanks in advance

Yes,

change this line

ratioH = 100/(mySelection[i].height/goal.height);

for this

ratioH = 100;

Tags: Illustrator

Similar Questions

  • Is it possible to modify this script to be reusable in a function?

    Hello

    I have this script inside a load of buttons (currently 16 individual buttons)

    They all have a different value and increment them positively and some negatively, they are + - buttons

    Here's the Script:

    var fldTI1 = this.getField ("20mmLeft");

    If (isNaN (fldTI1.value)) {}

    fldTI1.value = 0;

    }

    else {}

    fldTI1.value += 1;

    this.getField("LeftAddOnTotal").value += 20;

    }

    I wonder if I can do this more universal so that I don't have to write it in a function and call that function?

    I know that I'll probably have to write 2 functions for each value (15, 20, 35 and 50), one for the positive growth and the other for the negative increment.

    I was thinking something in the sense of the use of var fldT1 = this.getField (event.target.name); or something like that so that the var takes the name where the function was called?

    I tried to look in the syntax event.target and it does but I can't find an explanation clear about what it actually does.

    Any help and suggestions would be greatly appreciated.

    Thank you in advance!

    In general, I have to debug a problem like this, I would add the following line at the top of the function:

    app.alert("addOnValues: " + name + " " + name2 + " " + op + " " + amount);
    

    This will display all the parameters passed to the function and will show you that the service has got actually called. Alternatively, you can use the JavaScript debugger and set a breakpoint on the first line of this function and simple then the code.

    However, in this case, I can tell you what the problem is (the first time that I looked at your code, I only had that my cell phone, now that I'm working on the computer, it is easier to see what's going on): if/else if construct you use has the same conditions several times:

    if (op == "inc") {
      // ...
    }
    else if (op == "inc") {
      // ...
    }
    

    In an if/else if/else construction, only the first matching condition will be executed. After that, the shell passes at the end of the construction and running the following command. You will need to create if statements at two levels:

    if (op == "inc") {
        if (isNaN(fldName.value)) {
          // ...
        }
       else {
         // ...
       }
    }
    else if (op == "dec") {
       if (isNaN(fldName.value)) {
         // ...
       }
      else {
         // ...
      }
    }
    else {
         // ...
    }
    

    You can simplify this a little more because you know that the 'isNaN' case action is always the same, so you can use this:

    if (isNaN(fldName.value)) {
    }
    else if (op == "inc") {
    }
    else if (op == "dec") {
    }
    else {
    }
    

    Once again, it is quite normal JavaScript and has nothing to do with the implementation of Acrobat JavaScript. You can read on the basis of the JavaScript syntax.

  • How can I modify this script so it does not load in a new window?

    I have this script on an invisible button on a banner ad, but the customer does not want the linked page to open in a new window, but rather to load on the page in the same window. How can I change the script to achieve this, thank you!

    link_btn.addEventListener (MouseEvent.MOUSE_DOWN, mouseDownHandler);

    function mouseDownHandler(event:MouseEvent):void {}

    navigateToURL (new URLRequest ("http://www.sdesignsstore.com/store.html"));

    }

    Try...

    navigateToURL (new URLRequest ("http://www.sdesignsstore.com/store.html"), "_self");

  • Why the habit of this script work?

    Hello

    I've used this script to make a portrait scroll bar that works perfectly, however I modified the script to work in a landscape scroll bar by altering the x and the y axis and switching on the height to the width. However a portion of it will not work... The left and right arrows are working properly but the bar scroll do not move and I for the life of me understand why.

    Does anyone have any ideas as to what ive missed or done wrong?

    Thanks in advance

    scrolling = function () {}

    var scrollWidth:Number = scrollTrack._width;

    var contentWidth:Number = contentMain._width;

    var scrollFaceWidth:Number = scrollFace._width;

    var maskWidth:Number = maskedView._width;

    var initPosition:Number = scrollFace._x = scrollTrack._x;

    var initContentPos:Number = contentMain._x;

    var finalContentPos:Number = maskWidth-contentWidth + initContentPos;

    var left: Number = scrollTrack._y;

    var top: Number = scrollTrack._x;

    var right: Number = scrollTrack._y;

    lower var: Number = scrollTrack._width - scrollFaceWidth + scrollTrack._x;

    var dy:Number = 0;

    var speed: Number = 10;

    var moveVal:Number = (contentWidth-maskWidth) /(scrollWidth-scrollFaceWidth);

    scrollFace.onPress = function() {}

    var currPos:Number = this ._x;

    startDrag (this, false, left, top, right, bottom);

    this.onMouseMove = function() {}

    DY = Math.abs(initPosition-this._x);

    contentMain._x = Math.round(dy*-1*moveVal+initContentPos);

    };

    };

    scrollFace.onMouseUp = function() {}

    stopDrag();

    delete this.onMouseMove;

    };

    btnUp.onPress = function() {}

    this.onEnterFrame = function() {}

    If (contentMain._x + speed < maskedView._x) {}

    If (scrollFace._x < = high) {}

    scrollFace._x = top;

    } else {}

    scrollFace._x = speed/moveVal;

    }

    contentMain._x += speed;

    } else {}

    scrollFace._x = top;

    contentMain._x = maskedView._x;

    delete this.onEnterFrame;

    }

    };

    };

    btnUp.onDragOut = function() {}

    delete this.onEnterFrame;

    };

    btnUp.onRelease = function() {}

    delete this.onEnterFrame;

    };

    btnDown.onPress = function() {}

    this.onEnterFrame = function() {}

    If (contentMain._x - speed > finalContentPos) {}

    If (scrollFace._x > = bottom) {}

    scrollFace._x = low;

    } else {}

    moveVal/scrollFace._x += speed;

    }

    contentMain._x = speed;

    } else {}

    scrollFace._x = low;

    contentMain._x = finalContentPos;

    delete this.onEnterFrame;

    }

    };

    };

    btnDown.onRelease = function() {}

    delete this.onEnterFrame;

    };

    btnDown.onDragOut = function() {}

    delete this.onEnterFrame;

    };

    If (contentWidth < maskWidth) {}

    scrollFace._visible = false;

    btnUp.enabled = false;

    btnDown.enabled = false;

    } else {}

    scrollFace._visible = true;

    btnUp.enabled = true;

    btnDown.enabled = true;

    }

    };

    scrolling();

    Even with this reduction, it is at best a tangle of code to try to reason with him.  I think I see you have nested functions at least two levels deep, possibly further because I do not see where the original ends, and the nesting of functions is prevented best, and most often unnecessary...

    scrolling = function () {}

       scrollFace.onPress = function() {}

    this.onMouseMove = function() {}

    }

    };

    };

    Since you're telling the problem is that the scroll bar does not move, it does not move in relation to press the keys or does not move relative to slide.

  • Cleaning of the appearance of this script?

    Hello I had a ton of help here for this script. I've made a few changes and was wondering if it was possible to clean underside is the image and the Script so far. I would like the script to look like the lower part of the table in this photo.  The Commander of the top edge of the page is what is really at work right now.  Any help would be greatly appreciated.

    Screen Shot 2016-05-31 at 4.45.13 PM.png

    Here's the Script.

       function doTextFrameOnPageOne()  
        
     {  
     // Name of the Text Frame The Save information is in.
        var myBlendingSettings = { blendMode : BlendMode.OVERLAY };  
        var myTransparencySettings = { blendingSettings : myBlendingSettings };   
        var doc, tf, tvINFO, ip;  
            doc = app.activeDocument;  
    // TEXT FRAME PROPERTIES        
            tf = doc.pages[0].textFrames.add({ fillColor :"Yellow", fillTint: 20, transparencySettings : myTransparencySettings, geometricBounds: ['-.75','-4.45in','1.5in','-.75in'] });
    
    // Text frame information
            ip = tf.insertionPoints;
            ip[-1].contents = "Document:"+"\t "+ doc.name  +'\r'; 
            ip[-1].contents = "User Name:" +"\t"+ getAppUserName() +'\r';
            ip[-1].contents = "Computer Name:" +"\t"+ getLogInUserName()+'\r';
            tvINFO = ip[-1].textVariableInstances.add(LocationOptions.AFTER, ip[-1]);  
            "Date Modified:" +'\t'; tvINFO.associatedTextVariable = doc.textVariables.itemByName("Modification Date");  
            ip[-1].contents = '\r';
            tvINFO = ip[-1].textVariableInstances.add(LocationOptions.AFTER, ip[-1]);  
            tvINFO.associatedTextVariable = doc.textVariables.itemByName("Output Date");  
            ip[-1].contents = '\r';  
            tvINFO = ip[-1].textVariableInstances.add(LocationOptions.AFTER, ip[-1]);  
            tvINFO.associatedTextVariable = "Date Created:" +'\t'; doc.textVariables.itemByName("Creation Date");  
      
     // Change Properties of Text Frame.:                  }  
    

    Thank you

    Alain bombaert

    It was a question essentially about the creation of a table with ExtendScript for InDesign.

    Basically, you have two options here:

    [A] convert the text in your block of text in a table

    [B] create a new table and assign the content via the content of the table property

    [A] would essentially work for you.

    But as I can see from your first screenshot that this would not work as expected, if you are remodeling your current in a table content, because you are missing the required content of a column for some lines. Of more deviding tabs. If you provide, you can use the following code:

    tf.parentStory.texts[0].convertToTable("\t","\r");
    

    [B] would cooperate with the result of your functions and methods and the necessary channels for column one and two stored in one or two paintings.

    Example:

    var columnOneContentsArray =
    [
         "Document:" ,
         "User Name:",
         "Output Date:"
    ];
    
    var columnTwoContentsArray =
    [
         "USE FOR TEST SCRIPTS.indd" ,
         "Chris Bishop" ,
         "" // Not really necessary to use an empty string, but could be used to indicate, that this cell will be empty for now.
    ];
    
    var doc = app.documents.add();
    var tf = doc.textFrames.add({geometricBounds : [0,0,"100mm","100mm"]});
    var myTable = tf.texts[0].tables.add
    (
         {
              bodyRowCount : 3 , // You could use a larger number here, even if your contents array uses less entries.
              columnCount : 2 
    
              // Use other property/value pairs to define the width of the table, stroke weights, fill color etc.pp.
              // ...
         }
    );
    
    myTable.columns[0].contents = columnOneContentsArray;
    myTable.columns[1].contents = columnTwoContentsArray;
    

    In your case you leave the content of your text variables in the columnTwoContentsArray and replace their contents with an empty string "" maybe.

    Later, after creating the table, insert you the text variable in the right cell using the first insertion point of the cell.

    var cell3OfColumn2insertionPoint1 = myTable.columns[1].cells[2].insertionPoints[0];
    var tvINFO = cell3OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell3OfColumn2insertionPoint1);
    tvINFO.associatedTextVariable = doc.textVariables.itemByName("Output Date");
    

    Warning: Check, if your text variable already exists in your document.

    If so, use the existing one. If not, create a new.

    Note: I didn't test the extract with the text above variable.

    BTW. : this thread should go to the InDesign Scripting forum.

    Scripting InDesign

    Uwe

  • Is it possible to call a script of a speech file?

    Hi all

    TL; Dr. to access the tops of path with the expression does not seem possible, but can script, so is it possible to do it by calling a script inside the expression file?

    My goal is the number of vertices in path objects and use this value in an expression. The expression is the engine of offset property with a filling of the trajectory and the expression use a relative naming so that I can copy the path trim to 500 other groups of shape layers and have a different effect (speed of the offset) for each group according to the number of vertices of each path.

    I looked for a solution to this problem for some time now, and my conclusion is that you simply cannot access the tops of path with the expression, that the path is in a mask or a shape layer.

    Is this correct?

    With a mask on a solid layer and effects scripts guide after I should be able to:

    thisComp.layer("Black_Solid_1").mask ("mask 1") .maskPath .value

    or

    thisComp.layer("Black_Solid_1").mask ('mask 1'). maskPath.value .vertices

    or

    thisComp.layer("Black_Solid_1").mask ('mask 1'). maskPath.value.vertices .length

    I also tried:

    thisComp.layer("Black_Solid_1").mask ('mask 1'). maskPath.vertices .length

    and so on...

    But when you debug it with the source text of a text layer, I only get "undefined" for the value and errors for other expressions (' named 'summits' in class 'Property' property is missing or does not exist ").

    I am sure that these are the correct methods because many scripts use those, including:

    http://Omino.com/pixelblog/2008/12/25/AE-mask-vertices-from-Extendscript/

    http://www.crGreen.com/aescripts/actual_scripts/Connect_Point_to_Mask_Vertex.jsx

    http://aescripts.com/maskvertexexpression/

    So if it is not possible to directly access the berries of way by the expression, I thought the appellant, in every expression, an external script which would then return the number of vertices, there are in each table. It would look something like this (pseudo code):

    arrayLength =.content("Path_1").value.vertices.length content (.name thisProperty.propertyGroup (2))

    return arrayLength

    And then use the value I get the script to adjust speeds in my expressions:

    Time * arrayLength * thisComp.Layer ("Controller"). Effect ("Speed") ("Slider")

    Therefore, it is possible to call a script inside an expression file? How?

    If this isn't the case, you have any other suggestions?

    Thank you.

    Reference: After Effects Scripting Guide, page 172 CS6.

    You can use $. evalFile() to run an external file, but it will be executed by the expression engine, not script, so I don't think that helps you. I don't think that there is an automatic solution. I think you're stuck with manually executed a script once you modify the project for updating a cursor somewhere with the number of vertices.

    Dan

  • is it possible to write a script that will display the script files folder in the tree

    is it possible to write a script that will display the script files folder in the tree

    Yes :-)

    In your previous post, someone suggested to search for the file "SnpCreateTreeview.jsx", because it would just be the asked.

    The script can be found here, just accept the EULA and download the example scripts of Bridge CS3. (For some reason it is not in CS4 samples because as far as I know)

    Here's a version with small changes, it is up to you to point the script in the folder 'root' right, because this is, needless to C: on PC:

    ////////////////////////////////////////////////////////////////////////////
    ADOBE SYSTEMS INCORPORATED
    Copyright 2007 Adobe Systems Incorporated
    All rights reserved
    //
    NOTE: Adobe permits you to use, modify, and distribute this file according to the
    the terms of the Adobe license agreement accompanying it.  If you received this file from one
    source other than Adobe, then your use, modification or distribution of it is required in advance
    written permission from Adobe.
    /////////////////////////////////////////////////////////////////////////////

    /**
    @fileoverview shows how to use an item in the tree list and how to capture events with
    functions of recall or script registered event listeners.
    @class shows how to use an item in the tree list and how to capture events with
    functions of recall or script registered event listeners.

    Its use


      
      
      

        
    1. Run the extract in the ExtendScript Toolkit (see Readme.txt).
         
    2. Enlarge / reduce the list items
         
    3. Check the JavaScript Console to see the events captured by the elements of the TreeView.
       

    Description


     
     

    Creates two hierarchical list of TreeView items. One is static, with a fixed set of point
    nodes that you can expand and collapse. The other is dynamic; Item nodes are added and removed as
    the need for a view of the file system.
     
     

    The list items in the TreeView control to display the folders and files custom images.  When you add items to the
    TreeView list, type 'article' is used for elements of the leaf and 'node' to the elements of the container.
     
     

    Dynamic TreeView captures events in two different ways. It uses callback functions to capture the
    node to expand and collapse events and selection changes and also registers an event listener to
    capture double-click events.

    @constructor constructor
    */
    #targetengine "session".
    function SnpCreateTreeView()
    {
    /**
    The context in which this code snippet can work.
    @type string
    */
    this.requiredContext = "\tNeed runs in the context of the Bridge\n."

    /**
    The location of this script file system
    @type file
    */
    var scriptsFile = new File($.fileName);
       
    /**
    The location of the file system resource PNG file used to represent folders
    @type file
    */
    this.folderIcon = new file (scriptsFile.path + "/ resources/Folder_16x16.png");

    /**
    The location of the file system resource PNG file used to represent files
    @type file
    */
    this.fileIcon = new file (scriptsFile.path + "/ resources/Story_16x16.png");

    /**
    The root folder that will be used for the dynamic tree
    @type string
    */
    this.rootFolder

    If (File.fs is "Windows")
    {
    this.rootFolder = "C:";
    }
    on the other
    {
    this.rootFolder = ' / ';.
    }
    }

    /**
    Functional part of this code snippet. Creates the ScriptUI window and its components,
    and defines the behavior.
    @return true if the code snippet is executed as scheduled, false otherwise
    Boolean @type
    */
    SnpCreateTreeView.prototype.run = function()
    {

    $.writeln ("about to"run SnpCreateTreeView");
       
    Create the window
    var win = new window ("palette", "SnpCreateTreeView", undefined, {resizable: false});

    Create the Committee for the static TreeView control
    sPanel var = win.add ('Committee', undefined, 'TreeView Élément') static;
    sPanel.alignment = ["fill",""];
    sPanel.alignChildren = ["fill",""]

    Create a TreeView list
    sTv var = sPanel.add ("treeview");
    sTv.preferredSize = (300, 200);
    Add static items to the list, in a hierarchical structure.
    for (var i = 0; i)<>
    {
    sTv.add ("node", "Item" + i);
    for (var j = 0; j)<>
    {
    sTv.items [i] .add ("item", "Sub Item" + j);
    }
    }

    Create the Committee for the dynamic TreeView control
    var dPanel dynamic = win.add ('Committee', undefined, 'TreeView Élément');
    Create a TreeView list
    TV digital var = dPanel.add ("treeview", undefined);
    dTv.preferredSize = (400, 300);
    Create the root node element
    var aNode = dTv.add ("node", "/");
    Pair it with an image of the icon
    aNode.image = this.folderIcon;

    Define a handler for the double clicks
    myOnDoubleClick = Function
    {
    if(e.detail == 2)
    {
    $.writeln ("double click");
    }
    }

    Adds the handler as an event listener to the TreeView element.
    dTv.addEventListener ("click", myOnDoubleClick);

    Keep a reference to this object
    var that = this;

    Define an event handler for when a node is expanded
    dTv.onExpand = function (point)
    {
    $.writeln (item.text + "is now expanded.");
    nextItem var = item;
    var path = "";
    goUp var = true;

    While (goUp)
    {
    path = "/" + nextItem.text + path;
    nextItem = nextItem.parent;
    If (instanceof TreeView nextItem)
    {
    goUp = false;
    }
    }

    Remove all children of this element
    item.removeAll ();

    var Ref = new file (that.rootFolder + path);
    If (Ref instanceof Folder)
    {
    children var = ref.getFiles ();
    for (var i = 0; i)<>
    {
    If (children [i] instanceof file)
    {
    Item.Add ("node", children [i] p:System.NET.mail.MailAddress.DisplayName);
    Item.Items [i] .image = that.folderIcon;
    }
    on the other
    {
    Item.Add ("item", children [i] p:System.NET.mail.MailAddress.DisplayName);
    Item.Items [i] .image = that.fileIcon;
    }
    }
    }
    }

    Define an event handler for when a node is reduced
    dTv.onCollapse = function (point)
    {
    $.writeln (item.text + "is now reduced.");
    }

    Define an event handler for when the selection changes
    dTv.onChange = function()
    {
    $.writeln ("selection changed");
    }

    Display the window
    Win.Show ();
       
    $.writeln ("Ran SnpCreateTreeView");
       
    Returns true;
    }

    /**
    "main program": construct an anonymous instance and run
    as long as we are not unit - test this code snippet.
    */
    If (typeof (SnpCreateTreeView_unitTest) == 'undefined') {}
    new SnpCreateTreeView () .run ();
    }

  • I want to extract information from the same input field in multipal PDFs (created using document pro) and export them to an excel file. Is this possible? If this isn't the case, Adobe seeks to make this project a reality.

    I want to extract information from the same input field in multipal PDFs (created using document pro) and export them to an excel file. Is this possible? If this isn't the case, Adobe seeks to make this project a reality.

    -Extract all data from a single file can be done via the tools - forms - more form Options - export data...

    -Extract some data from a single file will require a script to measure.

    -Extract all the data from multiple fields in a single file can be done via the tools - forms - more form Options - merge data files into spreadsheet...

    -Extraction of data from several files will require a script Custom Action, as I've written before.

  • Need help to modify the Script to find the number of vCPU and reservation of memory in VC

    Hello

    Need help to modify the script so that his can person report to the vc all focus level instead of each level of the Cluster.

    Thank you

    KR

    Try this instead:

    $vmsInfo = Get-VM
    #Creating array to place new object
    
    $reportdata = @()
    
    Foreach ($vm in $vmsInfo)
    {
    #Creating new object
    $vmInfo = "" | Select Name, CPUReservationMHz, MemoryReservationGB
    $vmInfo.Name = $vm.Name
    $vmInfo.CPUReservationMHz = $vm.ExtensionData.ResourceConfig.CpuAllocation.Reservation
    $vmInfo.MemoryReservationGB = $vm.ExtensionData.ResourceConfig.MemoryAllocation.Reservation / 1024;
    #Inserting data into new object.
    $reportdata += $vminfo
    }
    $reportdata
    
  • Is it possible to write a script for underlined text export to PDF?

    When I make changes in the financial document, I must emphasize this purpose to show what I edit, these underscore was called "markup". And then print (paper version) and gen (PDF) of the amendment, which means I have to print and gen text underlined (or called markup text) after modification.

    sample PIC:

    back markup.jpg

    If:

    Customer requires a new version of the markup, which means I have to change the last beacon color (color of the underline to the last amendments) in 'back' and then make new 'red' as this markup:

    red markup.jpg

    What I want:

    is it possible to write a script for printing and gen only markup in the document text all open

    and I want two versions

    (1) all text markup gen no matter the color of the underline

    (2) the red color of the markup text gen

    Thank you!

    Hi HarveyLiu,

    Why, you ask? It will export the pages who pointed out the text.

    var doc = app.documents;
    app.findTextPreferences = null;
    app.findTextPreferences.underline = true;
    for(var i=0;i
    

    Kind regards

    Cognet

  • Update of this script?

    Hi-

    I have this script (various parts found on this forum) gives me some stats for daily and weekly activity on my virtual machine. How would I be able to date to a mini script also give me the details at intervals of 120 min with all the details below. So, for example, that pull one number for avg daily cpu and avg daily memory... that's fine, but how would also get the numbers of all the 120 minutes that make up this average sample? So what I'm looking for is essentially an extension of below to include numbers that make up these averages... which makes it easier to chart...

    Also, is there any removal of DiskIO is it possible to get as Mem and CPU? I had no idea how to get that.

    function {VM-statavg ($StatStart, $StatFinish, $vmImpl, $statId)

    $stats = $vmImpl | Get-stat - stat $statId intervalmin - 120 - maxsamples 360'

    -Launch $StatStart - finishing $StatFinish

    $statAvg = "{0, 9:.00 #} ' f ($stats |) Measure - Object value - average) subject

    $statAvg

    }

    $DaysBack = 1 # number of days to return back

    $DaysPeriod = 1 # number of days in the interval

    $DayStart = (get-Date). Date.AddDays(-$DaysBack)

    $DayFinish = (get-Date). Date.AddDays (-$DaysBack + $DaysPeriod).addminutes(-1)

    $DaysBack = 7 # number of days to return back

    $DaysPeriod = 7 # number of days in the interval

    $WeekStart = (get-Date). Date.AddDays(-$DaysBack)

    $WeekFinish = (get-Date). Date.AddDays (-$DaysBack + $DaysPeriod).addminutes(-1)

    $Report = @)

    Get - vm | Name - descending sort. % {

    $vm = get-view $_.ID

    $vms = "" | Select-Object VMName, DayAvgCpuUsage, WeekAvgCpuUsage, TotalCPU, TotalMemory, MemoryUsage, DayAvgMemUsage, WeekAvgMemUsage

    $vms. VMName = $vm. Name

    $vms. DayAvgCpuUsage = VM-statavg $_ $DayStart $DayFinish "cpu.usage.average".

    $vms. WeekAvgCpuUsage = VM-statavg $_ $WeekStart $WeekFinish "cpu.usage.average".

    $vms. TotalCPU = $vm.summary.config.numcpu

    $vms. TotalMemory = $vm.summary.config.memorysizemb

    $vms. MemoryUsage = $vm.summary.quickStats.guestMemoryUsage

    $vms. DayAvgMemUsage = VM-statavg $_ $DayStart $DayFinish "mem.usage.average".

    $vms. WeekAvgMemUsage = VM-statavg $_ $WeekStart $WeekFinish "mem.usage.average".

    }

    $Report |

    For the first part of your question, most of the information you want is already available.

    Because you wanted to on average during the day (or week) the script passed the statistical data for each interval of the Measure-Object cmdlet.

    So when simply omit us this cmdlet you will get all the statistical data not just the average.

    In the following script, I did exactly that:

    • create a new function, called VM-statavgArray, which leaves out the Measure-Object cmdlet and returns an array with all the statistical data

    • Add features to write all the statistical data in a CSV file that is individual for each guest

    From there on, it should be easy to put these values in a chart.

    The script shows that the average utilization of the CPU for 1 night.

    Data last week and for the memory statistics can be done similarly.

    function VM-statavgArray ($vmImpl, $StatStart, $StatFinish, $statId) {
            $vmImpl | get-stat -stat $statId -intervalmin 120 -maxsamples 360 `
            -Start $StatStart -Finish $StatFinish
    }
    #Report for previous day
    $DaysBack = 1 # Number of days to go back
    $DaysPeriod = 1 # Number of days in the interval
    $DayStart = (Get-Date).Date.adddays(- $DaysBack)
    $DayFinish = (Get-Date).Date.adddays(- $DaysBack + $DaysPeriod).addminutes(-1) 
    
    $Report = @()
    get-vm | Sort Name -Descending | % {
            $vm = Get-View $_.ID
            $DayCpuUsage = VM-statavgArray $_ $DayStart $DayFinish "cpu.usage.average"
            if($DayCpuUsage -ne $null){
                    $report = @()
                    foreach($line in $DayCpuUsage){
                            $row = "" | Select Timestamp, Value
                            $row.Timestamp = $line.Timestamp
                            $row.Value = $line.Value
                            $report += $row
                    }
                    $Report | Export-Csv ("C:\" + $vm.Name + "-DayCpuUsage.csv") -noTypeInformation
            }
    }
    

    For the second part of your question.

    You can get the disk with the disk.usage.average metric usage statistics.

    Note that this will return, in Kbps, the sum of the data read and written to all instances of the virtual machine disk.

    You can use the similar script logic as in the previous script for this measure.

    If you want to see statistics of disk i/o for individual disks, you must use the disk.read.average and disk.write.average parameters.

    But note that you need to filter on the Instance property to select the disc you want.

    Also note that the instances are the drives connected to the ESX Server is not the virtual disks connected to the virtual machine.

    You need to add the disk.read.average and disk.write.average values for the total i/o to the individual drive.

    function VM-statavgArray ($vmImpl, $StatStart, $StatFinish, $statId) {
            $vmImpl | get-stat -stat $statId -intervalmin 120 -maxsamples 360 `
            -Start $StatStart -Finish $StatFinish
    }
    #Report for previous day
    $DaysBack = 1 # Number of days to go back
    $DaysPeriod = 1 # Number of days in the interval
    $DayStart = (Get-Date).Date.adddays(- $DaysBack)
    $DayFinish = (Get-Date).Date.adddays(- $DaysBack + $DaysPeriod).addminutes(-1) 
    
    $Report = @()
    get-vm | Sort Name -Descending | % {
            $vm = Get-View $_.ID
            $DayDiskRead = VM-statavgArray $_ $DayStart $DayFinish "disk.read.average"
            if($DayDiskRead -ne $null){
                    $report = @()
                    foreach($line in $DayDiskRead){
                            $row = "" | Select Timestamp, Instance, Value
                            $row.Timestamp = $line.Timestamp
                            $row.Value = $line.Value
                            $row.Instance = $line.Instance
                            $report += $row
                    }
                    $Report | Export-Csv ("C:\" + $vm.Name + "-DayDiskReadAvg.csv") -noTypeInformation
            }
    }
    

    Note that you need to set the historical interval corresponding to 120 minutes at least to level 3 to collect these statistics of the device.

  • Why won't this script work?

    Well so yesterday I posted a question I had with join InDesign files, I thought that I had found a solution and I was wrong. Nothing is as humbling as script... anyway the gist of what I'm trying to do is trying to combine a lot of InDesign files in a single large document. The problem I encounter is that InDesign crashes. What is strange to me is that a single iteration of this script works oddly, however when I try to do with multiple InDesign files * the bed.

    Any help on the figure, it would be much appreciated.

    System: WIndows 7

    Indy Version: CS5

    (1) selecting a folder.

    (2) get the files.

    (3) open one at a time, and duplicate pages in another document. (Which I call OCD because I basically that is what I want to do with the giant document.)

    (4) close the source file without saving the changes. Pages should not change, but better safe than sorry.

    (5) close the (TOC) destination file and save it with the new pages to this subject.

    inDesign #target

    File = Folder.selectDialog ();

    files = folder.getFiles ("*.") INDD");

    for (var i = 0; i < files.length; i ++) {}

    source_doc = app.open (files [i]);

    destination_doc = app.open (file ("c: / / users//user//desktop//TOC.indd"))

    REST();

    }

    function rest() {}

    sourcePages = source_doc.pages.itemByRange (0, -1);

    sourcePages.duplicate (LocationOptions.AFTER, destination_doc.pages.item(-1));

    source_doc. Close (SaveOptions.no);

    destination_doc. Close (SaveOptions.YES, "c://users//user//desktop//TOC.indd");

    }

    Couple of thoughts: the code is kind of a mess. I don't understand why you are opening and closing of your doc of destination with each iteration, or why you have stuff separated in another function, or why you have not any vars. As a general rule, I try to work on spreads rather than pages where possible. I avoid also itemByRange() because of the strange plural object that it returns. Here's one (in my opinion, in any case) cleaned script:

    var folder = Folder.selectDialog(),
        files = folder.getFiles("*.INDD"),
        destination_doc = app.open(new File("c://users//user//desktop//TOC.indd")),
        source_doc, i, j;
    
    for (i = 0; i < files.length; i++) {
        source_doc = app.open(files[i]);
        for (j = 0; j < source_doc.spreads.length; j++) {
            source_doc.spreads[j].duplicate(LocationOptions.AT_END, destination_doc);
        }
        source_doc.close(SaveOptions.NO);
    }
    
    destination_doc.close(SaveOptions.YES);
    

    See if you have better luck with it.

    Jeff

  • Is it possible to use a Script in action? -It doesn't seem to work...

    Is it possible to use a Script in action? -It doesn't seem to work...

    I use the script "around any corner" of SATO Hiroyuki..., and I want to apply to only one anchor (on multiple boxes)

    An Action can call a script in the file > Scripts menu through the point of Menu Add Action step. But it works only for the duration of your Illustrator work session. IF you exit and then restart, the add step Menu item will be empty. This bug has been reported for the COMPLETE FOUR VERSIONS of this botched program.

    However, if I understand your description of what you're trying to automate an Action won't able to automate the selection of a particular anchorpoint several paths. You will need to perform the selections at the beginning. If the script would then apply as you wish to each path depends on the way in which the script is written.

    JET

  • Is it possible to run a script on a file of entire book?

    Hello world.

    Like the stuff of script. Juice I was wondering, is it possible to tell a script to run on a file integer indb?

    Thank you

    Mary

    Hi marykulp,

    If you have the script and you have a book, you can open each doc book and run the script.

    By script, you can automate the docs of the opening book and call a script designed to do something with the active document by doScript().

    Review the script doScriptWithDocsOfBooks.jsx.

    This could be useful for you.

    You must select a script and the script "doScriptWithDocsOfBooks.jsx" will open all documents in each book open in loops and run the selected script.

    Do not forget that the selected script meets the active document at the same time.

    Martin

  • Is it possible to modify an existing join, and more?

    In Discoverer Plus, is it possible to modify a join in a relationship? Currently I have only access to the office (10.1.2.2), but if it can be done more it is perhaps something worth pursuing.

    My situation is, I have a pretty complex spreadsheet where I need to change an existing join to an outer join. I can't change the join itself, in Admin - which would affect the other reports that use it. I know that in the office, if I remove all the elements of the joined table (including the Calc and conditions that reference), and then add them back, it will prompt me for how to use join. However, in this case, at the time when I remove and re-add all of these, I basically had to rewrite the report.

    I'm sure that's what I have to do, but I hope that someone will be aware of a workaround that I'm missing. If access to the more will make things easier, it would be worth.

    Thank you!

    Hello
    I'm afraid you would fare no better and more is like the same thing will happen here. You need to remove all the elements that use the existing join as soon as you start adding back in you will be asked to choose a join.

    There are many good reasons to use, this is not one of them as the feature, or lack of function from your point of view, is the same.

    Best wishes
    Michael

Maybe you are looking for