How to measure the distance using script

Hi
Is there any way to measure the distance of any photoshop document using the measure tool, by using the script. Given below the steps required by me. Hope i'm clear in my communications.
I searched the forums but couldnt find any suitable answers.
1.Open Photoshop document
2. Allow the user to draw the line using measure tool
3. alert the distance
Rgs
Anish

Michael L Hale wrote:
Sorry maybe I wasn't clear. If you want the angle reported by the script to match what would be reported if the user used the line tool you do need to make the path left to right.
That would only be half right as you can use the ruler measure tool from left to right and right to left a full 360 the angles reported will be in the range of 0 to +|-180 if you limit it to left to right the angle range will be from +90 to -90.
I understand your statement for "var ang = (180/Math.PI) * Math.atan2(o,a);" will only generate the angle for a right triangle 0 through 90.   That is why I wrote the sign was an indication of direction meaning up or down but the problem is that there are two -45 and two +45  the other directiom left or right is only known by the line tool user. I do not understand path points you use lineStart[1] < lineEnd[1]to find out up or down perhaps some other comparison can find out left or right and then adjust the angle if to the right by to the range from +|-90 to +|-180.
I think I did it now matches the line tool left to right or right to left the angle now matches the ruler measure tool when ruler unites is set to pixels
// enable double-clicking from Mac Finder or Windows Explorer
#target photoshop // this command only works in Photoshop CS2 and higher
// bring application forward for double-click events
app.bringToFront();
// ensure at least one document open
if (!documents.length) alert('There are no documents open.', 'No Document');
else {
          main(); // at least one document exists proceed
//                            main function                                  //
function main() {
          // declare local variables
          var orig_ruler_units = app.preferences.rulerUnits;
          app.preferences.rulerUnits = Units.PIXELS;          // Set the ruler units to PIXELS
          try { alert(measureLine(app.activeDocument.pathItems.getByName("Work Path"))); }
          // display error message if something goes wrong
          catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }
          app.preferences.rulerUnits = orig_ruler_units;          // Reset units to original settings
//                           main function end                               //
//the code below is for the Line tool.
function measureLine(path){
          var res = new Array;
          var lineStart = path.subPathItems[0].pathPoints[0].anchor;
          var lineEnd = path.subPathItems[0].pathPoints[3].anchor;
          var a = Math.max(lineStart[0],lineEnd[0])-Math.min(lineStart[0],lineEnd[0]);
          var o = Math.max(lineStart[1],lineEnd[1])-Math.min(lineStart[1],lineEnd[1]);
          var c = Math.round(Math.sqrt((a*a)+(o*o)));
          //alert("Triangle Height = " + o + " Width = " + a + " Hypotenuse = " + c );
          res.push(c);
          var ang = (180/Math.PI) * Math.atan2(o,a);
          if(lineStart[0] > lineEnd[0]){//To the left
                    ang = 180-ang;
          if(lineStart[1] < lineEnd[1]){//Down
                    ang = -ang;
          res.push(ang);
          return res;
Message was edited by: JJMack

Similar Messages

  • How to measure the rpm using NI 9411 and counters

    How to calculate the rpm of a shaft using NI 9411 and counters?

    http://forums.ni.com/t5/Signal-Conditioning/measuring-rpm-using-DAQ-device/m-p/2571131#M7353
    Additionally, if you set it to read a degree instead of pulse, your calculation will change a bit, but I'll leave that to you.

  • How to measure the pulse duration of a TTL signal using AI?

    Hi there.
    I would like to know how to measure the pulse duration of a TTL signal using an Analog input.
    These TTL signals comes from an ultrasonic sensor's output. The pulse width of the signal is
    proportional to the distance of the object the sensor detected.
    I have tried using the example "Measure Pulse Width.vi" which uses a counter to measure the
    pulse duration instead. It provides me with correct results.
    However, i will like to know how can i do it using the AI instead.
    I tried it by using the example "Acq&Graph Voltage-Int Clk.vi" which i modified by including a
    timing and transistion measurement vi. Pulse duration was selected as the output. A graph indicator was also added at the output of the pulse duration to monitor the incoming TTL signals.
    However, everytime the TTL signals was detected on the graph indicator, the numeric indicator always produce a "zero" reading.
    I have attached my vi for your reference.
    Can anybody advice me what i have done wrongly?
    Regard.
    Attachments:
    Acq&Graph Voltage-Int Clkv1.vi ‏190 KB

    Hi Paul,
    Today i tried using 2 different methods to read the pulse duration of my sensor signal.
    Both methods use "Acq&Graph Voltage-IntClk" vi as a guide.
    Method1:
    Add a filter vi(lowpass/bandpass) and a timing and transition measurements vi.
    Pulse duration is selected as the output. With some numeric conversion, a centimeter
    reading indicator was created. However, the reading always remains as "zero"
    Method2:
    Add a Mask and Limit Testing vi and a timing and transition measurements vi.
    By adjusting my upper and lower limits, i manage to "filter" a single pulse out from the actual signal.
    However, like the earlier case, the cm reading still remains at "zero"
    I have attached both the methods resulted waveforms for your reference.
    Are there anything that you can advice on?
    Regard.
    Attachments:
    Results_Waveforms.doc ‏141 KB

  • How to get the handle of all text fields in the subforms, using script

    Hi Friends,
    I have around 20 fields in a subform, how can i get the names of all the fields using script.
    I wish to enhance the following script where the field names are hard coded
    thereby the script itself will get the names of the field names.
    var f1 = this.parent.somExpression + ".TextField2" + ",";
    var f2 = f1 + this.parent.somExpression + ".DropDownList1" + ",";
    var f3 = f2 + this.parent.somExpression + ".NumericField1";
    xfa.host.resetData(f3);
    Any help will be greatly appreciated..
    Thanks
    JJ

    Hi Paul,
    Thanks for your comments.
    I achieved the clear contents by resetting, by taking input from your thoughts..
    form1.sub1.sub2.sub3.table_1.addDelete_Top.addDelete.deleteRow::click - (JavaScript, client)
    //Here is my code finally look like..
    //row 1, table_1 are also subforms
    for (var i=1;i<10;i++){
    var myRow = this.resolveNode("table_1.row1[" + i + "]");
    if(myRow.presence == "hidden"){
    i = i-1;
    var myRowDelete = this.resolveNode("table_1.row1[" + i + "]");
    if(i!=0){
    xfa.host.resetData(myRowDelete.somExpression);
    myRowDelete.presence = "hidden";
    break;
    if(i==9){
    xfa.host.resetData(myRow.somExpression);
    myRow.presence = "hidden";
    break;
    Thanks
    JJ

  • How to measure the baseline of a noisy, pulsed signal

    Hi
    I am measuring the torque exerted by a large motor on a shaft using a load cell and lever arm. The shaft runs at approx 150 rpm. I have attached a drawing that shows the output I get. This is a test rig.
    I have written some code that measures the maximum peak out of a group of approx 5 peaks and writes this to a shift register. This gives me an idea of the maximum torque "spike".
    I also wish to measure the baseline torque (due to the bearings in the machine). Even when highly filtered (my noise filter is set to 49Hz) the signal exhibits this noise which is probably due to vibration in the system. The signal is zeroed when the motor is not running.
    Does anyone have an ideas on how to measure the "baseline" torque? The large spike in torque prevents me from doing a running average. Can anyone think of a way of averaging just the noisy part of the signal to get an average value? I aim to to subtract the average baseline torque from the peak value to get an idea of the torque due to the event which causes
    the spike.
    Any help would be greatly appreciated.
    Many thanks.
    Attachments:
    drawing of torque signal.gif ‏26 KB

    Thanks for the reply. I understand what you are saying. However, I might have to modify my method for measuring the peaks if I choose to implement your idea. I have taken a screenshot of my "peak finder" code and attached it.
    Bascially, the reset terminal is wired to a timer which outputs a pulse every few seconds. This resets the vi (a standard NI one I think) and sets the peak magnitude back to zero. This way, I am windowing the signal and measuring the maximum peak in every window. This is what I need to do.
    So I could use a logical filter to feed data to the running average only if;
    the amplitude of the signal is less than a certain threshold
    and if the current value has similar low peaks either side of it
    How would you construct the code to delay the evaluation so that the values in front and behind of the current data point can be analysed?
    thanks again
    Attachments:
    peak_find_screenshot.jpg ‏45 KB

  • How to measure the performance of sql query?

    Hi Experts,
    How to measure the performance, efficiency and cpu cost of a sql query?
    What are all the measures available for an sql query?
    How to identify i am writing optimal query?
    I am using Oracle 9i...
    It ll be useful for me to write efficient query....
    Thanks & Regards

    psram wrote:
    Hi Experts,
    How to measure the performance, efficiency and cpu cost of a sql query?
    What are all the measures available for an sql query?
    How to identify i am writing optimal query?
    I am using Oracle 9i... You might want to start with a feature of SQL*Plus: The AUTOTRACE (TRACEONLY) option which executes your statement, fetches all records (if there is something to fetch) and shows you some basic statistics information, which include the number of logical I/Os performed, number of sorts etc.
    This gives you an indication of the effectiveness of your statement, so that can check how many logical I/Os (and physical reads) had to be performed.
    Note however that there are more things to consider, as you've already mentioned: The CPU bit is not included in these statistics, and the work performed by SQL workareas (e.g. by hash joins) is also credited only very limited (number of sorts), but e.g. it doesn't cover any writes to temporary segments due to sort or hash operations spilling to disk etc.
    You can use the following approach to get a deeper understanding of the operations performed by each row source:
    alter session set statistics_level=all;
    alter session set timed_statistics = true;
    select /* findme */ ... <your query here>
    SELECT
             SUBSTR(LPAD(' ',DEPTH - 1)||OPERATION||' '||OBJECT_NAME,1,40) OPERATION,
             OBJECT_NAME,
             CARDINALITY,
             LAST_OUTPUT_ROWS,
             LAST_CR_BUFFER_GETS,
             LAST_DISK_READS,
             LAST_DISK_WRITES,
    FROM     V$SQL_PLAN_STATISTICS_ALL P,
             (SELECT *
              FROM   (SELECT   *
                      FROM     V$SQL
                      WHERE    SQL_TEXT LIKE '%findme%'
                               AND SQL_TEXT NOT LIKE '%V$SQL%'
                               AND PARSING_USER_ID = SYS_CONTEXT('USERENV','CURRENT_USERID')
                      ORDER BY LAST_LOAD_TIME DESC)
              WHERE  ROWNUM < 2) S
    WHERE    S.HASH_VALUE = P.HASH_VALUE
             AND S.CHILD_NUMBER = P.CHILD_NUMBER
    ORDER BY ID
    /Check the V$SQL_PLAN_STATISTICS_ALL view for more statistics available. In 10g there is a convenient function DBMS_XPLAN.DISPLAY_CURSOR which can show this information with a single call, but in 9i you need to do it yourself.
    Note that "statistics_level=all" adds a significant overhead to the processing, so use with care and only when required:
    http://jonathanlewis.wordpress.com/2007/11/25/gather_plan_statistics/
    http://jonathanlewis.wordpress.com/2007/04/26/heisenberg/
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • How to measure the size of a string

    windows app store how to measure the size of a string?
    string str = "Hello word windows app store";

    if you need the actual width the string occupies in pixels than use (see
    this MSDN link for more details):
    Graphics.MeasureString(String, Font)
    if you only need the "length" of the string i.e. no. of characters than use (see
    this MSDN link for more details):
    str.Length
    dont forget to bing / google :)
    hope this helps!
    Graphics.MeasureString(String, Font) can not use in windows store app.
    TextBlock has Measure()
    method, as following:
    Size MeasureString(string content, Size availableSize, double fontSize, string fontFamily="Segoe UI")
        TextBlock tb = new TextBlock();
        tb.TextWrapping = TextWrapping.Wrap;
        tb.Text = content;
        tb.FontFamily = new Windows.UI.Xaml.Media.FontFamily(fontFamily);
        tb.FontSize = fontSize;
        tb.Measure(availableSize);
        return tb.DesiredSize;
    Test:
    string str = "Hello word windows app store";
    Size size = MeasureString(str, new Size(800, 600), 40);

  • How to measure the InfoCube size?

    can any body help me regarding this
    how to measure the info cube size?

    1. use transaction se16, infocube table /../f[infocube name] and /.../e[infocube name], count 'number of entries' - total records
    use transaction db02 tablename infocubename - size in bytes
    Re: how can we measure the info cube size
    2. asap methodology
    Re: Lifecycle Implementation
    hope this helps.
    regards
    harikrishna N

  • How to measure the task instance size

    I am trying to understand how to measure the custom task instnace size that was occupied in the cache repository. Is there a way to obtain the size (in KB s ) in lighthouse 4.1 +sp5. Please help.                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi, Luiz!
    In order to estimate the instance size, you will have to sum up all the instance variables size.
    From the practical prospective it may be difficult to use the algorithm in cases when your instance variables are not simple types.
    For already existing instances, you can look the instance size in the database:
    An instance is just a java object, that is serialized as a byte[] and stored in the engine database, PPROCINSTANCE table, column INSTDATA.
    You can write a simple program (either java or SQL plus) that would read the instance from the BLOB and measure the size.
    And yes, with large instances you can have performance problems.

  • How to run the job using DBMS_SCHEDULER

    How to run the job using DBMS_SCHEDULER
    pleas give some sample Iam very new to DBMS_SCHEDULER

    Hi
    DBMS_SCHEDULER
    In Oracle 10g the DBMS_JOB package is replaced by the DBMS_SCHEDULER package. The DBMS_JOB package is now depricated and in Oracle 10g it's only provided for backward compatibility. From Oracle 10g the DBMS_JOB package should not be used any more, because is could not exist in a future version of Oracle.
    With DBMS_SCHEDULER Oracle procedures and functions can be executed. Also binary and shell-scripts can be scheduled.
    Rights
    If you have DBA rights you can do all the scheduling. For administering job scheduling you need the privileges belonging to the SCHEDULER_ADMIN role. To create and run jobs in your own schedule you need the 'CREATE JOB' privilege.
    With DBMS_JOB you needed to set an initialization parameter to start a job coordinator background process. With Oracle 10g DBMS_SCHEDULER this is not needed any more.
    If you want to user resource plans and/or consumer groups you need to set a system parameter:
    ALTER SYSTEM SET RESOURCE_LIMIT = TRUE;
    Baisc Parts: Job
    A job instructs the scheduler to run a specific program at a specific time on a specific date.
    Programs
    A program contains the code (or reference to the code ) that needs to be run to accomplish a task. It also contains parameters that should be passed to the program at runtime. And it?s an independent object that can referenced by many jobs
    Schedules
    A schedule contains a start date, an optional end date, and repeat interval with these elements; an execution schedule can be calculated.
    Windows
    A window identifies a recurring block of time during which a specific resource plan should be enabled to govern resource allocation for the database.
    Job groups
    A job group is a logical method of classifying jobs with similar characteristics.
    Window groups
    A window groups is a logical method of grouping windows. They simplify the management of windows by allowing the members of the group to be manipulated as one object. Unlike job groups, window groups don?t set default characteristics for windows that belong to the group.
    Using Job Scheduler
    SQL> drop table emp;
    SQL> Create table emp (eno int, esal int);
    SQL > begin
    dbms_scheduler.create_job (
    job_name => 'test_abc',
    job_type => 'PLSQL_BLOCK',
    job_action => 'update emp set esal=esal*10 ;',
    start_date => SYSDATE,
    repeat_interval => 'FREQ=DAILY; INTERVAL=10',
    comments => 'Iam tesing scheduler');
    end;
    PL/SQL procedure successfully completed.
    Verification
    To verify that job was created, the DBA | ALL | USER_SCHEDULER_JOBS view can be queried.
    SQL> select job_name,enabled,run_count from user_scheduler_jobs;
    JOB_NAME ENABL RUN_COUNT
    TEST_abc FALSE 0
    Note :
    As you can see from the results, the job was indeed created, but is not enabled because the ENABLE attribute was not explicitly set in the CREATE_JOB procedure.
    Run your job
    SQL> begin
    2 dbms_scheduler.run_job('TEST_abc',TRUE);
    3* end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> select job_name,enabled,run_count from user_scheduler_jobs;
    JOB_NAME ENABL RUN_COUNT
    TEST_ABC FALSE 0
    Copying Jobs
    SQL> begin
    2 dbms_scheduler.copy_job('TEST_ABC','NEW_TEST_ABC');
    3 END;
    4 /
    PL/SQL procedure successfully completed. Hope it will help you upto some level..!!
    Regards
    K

  • Can i measure moving distance using after effects?

    can i measure moving distance using after effects?

    I don't know what you mean. If you mean take measurements like you can in Photoshop and relating them to the real world then the answer is not easily. No Effect I know of allows you to do that. If you mean measuring the distance in pixels a layer moves on any axis, yes you can measure that and display the result using an expression by either referring to a valueAtTime of a keyframe or a layer marker. For a layer marker for example showing the X distance a layer moves starting at first layer marker you would add this expression to the source text of a blank text layer. The moving layer would be named "target."
    t = thisComp.layer("target");
    mp = t.marker.key(1).time;
    ip = t.position.valueAtTime(mp);
    np = t.position[0] - ip[0];
    Math.round(np)
    If the layer is moving left to right and the marker is in the middle of the layer then the numbers will be negative until the marker is reached, zero at the marker, then positive after the marker is past.

  • How to execute the job from script ??

    How to execute the job from script ?? i have 2 jobs  A AND B . I want to execute job B  from job A'S Script ?? how can i ??

    Hi Kishore,
    Please refer the below link for BODS Job execution using Script
    Executing a job by another job in BODS 4.1 using simple script
    http://scn.sap.com/community/data-services/blog/2013/12/04/executing-a-job-by-another-job-in-bods-41-using-simple-script
    Steps for executing BODS job from Unix Script with user defined global parameters
    http://scn.sap.com/community/data-services/blog/2013/09/02/steps-for-executing-bods-job-from-unix-script-with-user-defined-global-parameters
    Executing a job using batch file
    http://scn.sap.com/thread/3503338
    How to add a schedule for job2 with a condition after job 1 is finished
    http://scn.sap.com/message/14523514#14523514
    Scheduling BODS Jobs Sequentially and Conditionally
    http://scn.sap.com/docs/DOC-34648
    Thanks,
    Daya

  • How to log the exception using Log action in Oracle Service Bus

    Hi,
    Whenever an exception is raised how to log the exception using Log action in oracle service bus.After logging where I have to find the logged message.

    It would be in the log file for the managed server which ran the request. If you are logging the message at a lower level than your app server, however, you won't see it. You should be logging the exception at Error level.

  • How to change the Default login script and the USER login script in Netware3.12

    I need to cut down the disk map from Neware 3.12 in Win98 client's PC.
    please tell me
    how to change the Default login script and the USER login script in
    Netware3.12 ?
    Or is there any other ways to do this thing?
    Thanks a lot!

    On 4/6/2006 [email protected] wrote:
    > how to change the Default login script and the USER login script in
    > Netware3.12 ?
    Please repost in the discontinued.forums.
    Edison Ortiz
    Novell Product Support Forum SysOp
    (No Email Support, Thanks !)

  • How to measure the performance of Extractor

    Hi,
    How to measure the time taken to by the extractor when executed from rsa3 for a given selection?
    Lot of threads speak about ST05... but these transactions are too granular to analyse.
    How to get the overall time taken.i need the overall time taken and the time taken by the individual SQL statements... please provide specific pointers.
    Thanks,
    Balaji

    Maybe SE30 can help you....
    Regards,
    Fred

Maybe you are looking for