Execute and return a value (or object) from another script

I wish I could have some of the functions of the little that I often use in my scripts, just like seporate scripts. so I can then update in one place and do not copy in every script, I want to use them in.

I don't know if this is possible at all. But I'd love to be able to just call them and return of their share values somehow.

for example

Swatches of color key code, I need:

        var inCutColorCMYK = cmykColor(50, 0, 100, 0);
        var intCutSPOT = makeSwatch("CutIN", inCutColorCMYK);

so I have these functions I have tweeked/found:

   function makeSwatch( swName, swCol) {  
    var doc = app.activeDocument;
    var sel = doc.selection;
    if (!inCollection(doc.swatches, swName)) {  
    var aSwatch = doc.spots.add();  
    aSwatch.name = swName;  
    aSwatch.color = swCol;  
    aSwatch.tint = 100;  
    aSwatch.colorType = ColorModel.SPOT;  
    var aSwatchSpot = new SpotColor();  
    aSwatchSpot.spot = aSwatch;  
    return aSwatchSpot;  
    }else{  
        return doc.swatches.getByName(swName);  
        }  
    };


function cmykColor(c, m, y, k) {  
    var newCMYK = new CMYKColor();  
    newCMYK.cyan = c;  
    newCMYK.magenta = m;  
    newCMYK.yellow = y;  
    newCMYK.black = k;  
    return newCMYK;  
    };




function inCollection(collection, nameString) {  
       var exists = false;  
   try{
    for (var i = 0; i < collection.length; i++) {  
        if (collection[i].name == nameString) {  
            exists = true;  
            }  
        }  
    }catch(e){//alert("Illustrator needs drop kicked!!\nPlease restart Illustrator :/\n\n"+e)
        }
        return exists;  
        
      };

in any case! I keep finding my self using functions like that again and again new scripts and hope there is a way to do this!

Any help is appreciated!

-Boyd

You have the file a.jsx, something like myLibrary.jsx, and in it, you can have all the functions for future use. In the file, it can look like this:

------------------------------------ Library file -----------------------------------

#target illustrator

function MyLibrary() {}

this.cmykColor = function (c, m, y, k) {}

var newCMYK = new CMYKColor();

newCMYK.cyan = c;

newCMYK.magenta = m;

newCMYK.yellow = y;

newCMYK.black = k;

Return newCMYK;

};

function applyFillColorTo (item, color) {}

item.fillColor = color;

}

function CataloguedPathItem (pathItem) {}

var p = pathItem;

p.applyFillColor = {function (color)}

applyFillColorTo (this, color);

};

return p;

}

this.cataloguedPathItem = {function (pathItem)}

var p = new CataloguedPathItem (pathItem);

return p;

}

};

----------------------------------------------------------------------------------------

And then you can understand and use this file in other scripts, like here:
-------------------------------------- Script File ---------------------------------

#target illustrator

#include 'C:\\Users\\Me\\Desktop\\My Adobe Scripts\\Illustrator\\MyLibrary.jsx.

function test() {}

var MyLib = new MyLibrary(); the script library is used as an object - elements of its scope of application are available through point (.) as mylib.myFunction ();

If (app.documents.length > 0) {}

var doc = app.activeDocument;

If (doc.selection.length > 0) {}

var MonElement = mylib.cataloguedPathItem(doc.selection[0]);

var mylib.cmykColor (0,100,50,0) = myColor;

myItem.applyFillColor (myColor);

}

} else {}

Alert ("there is no open document.");

}

}

test();

----------------------------------------------------------------------------------------

The colors test script just a pathItem, but it uses functions from the inside of the object of 'library' to power the process. Note that to use the library of color a path implied instantiate this path as a custom which is a 'applyFillColor' method that uses a function of the scope of the library (called "applyFillColorTo") for power. Then, we can not simply the function "applyFillColorTo" use within the scope of the Script file because it is protected by the MyLibrary object.

Tags: Illustrator

Similar Questions

  • I'm updating photoshop today and when I drag an object from illustrator to photoshop, the object doesn't turn into a dynamic object why?

    Update photoshop today and when I drag an object from illustrator to photoshop object market not turning into a smart object why?

    OK - think I have this sorted out now.

    When you copy and paste an Illustrator file in Photoshop, you get the dialog box PASTE.

    You can paste as smart object, Pixels, path and shape layer. In the past, you would select depending on what you want (in my case for most Smart Object) and viola - you have your dynamic object. However, in the newly revised version, there is a checkbox in low called "Add to my current library" If this box is checked, it becomes a library file that displays with a 'cloud' icon in the layer. If you uncheck the 'Add to my current library' it won't matter as a regular smart object.

  • Partition question - what would be the best way to increase its space and take part of the space from another partition

    Hello, I have my 500 GB SATA broken down into 3 partitions. Vista and 2 others. The problem is the process of using Partition Magic, Vista has been given only 30 GB, now its operation with 1-2 GB of free space. I want to know what would be the best way to increase its space and take part of the space from another partition, but I don't want to have to reinstall or do I want to lose all the data like photos, browser, documents and news ect.

    -Thank you

     

    You can read more details on "How to move from one partition to the other sapce without loss of data.

  • How to execute a Perl script and returns the value as a string?

    Hi, I am trying to build an application using the eclipse 2.0.0 with the Blackberry SDK 7.1 plug-in. currently I tested Simulator 9900 version 7.1.0.523. I need to use the Perl language to access the raw biological database and returns as a string without having to write a longer program using java.

    In a stand alone Java SDK, I can use the line:

    Process p = Runtime.getRuntime () .exec ("perl script.pl")

    but when I tried to use it on the IDE for a Blackberry project, the project will not compile. It is said:

    Method exec (String) is undefined for the type of Runtime

    Hopes, can someone show me the correct syntex to use, but if no class is available, could someone show me a sample for unified research process? The names of blackberry dev is very complicated, I can't find any samples for her.

    Thank you.

    Seems interesting.

    Your idea was to download the data to the BlackBerry and then directly execute queries.

    Although there are a number of other obstacles, the first fall you in East platforms supporting Perl.  Here is the list:

    http://perldoc.Perl.org/perlport.html#supported-platforms

    BlackBerry OS Java is not included - in fact the only ' included phone OS is Symbian.  Interestingly, it seems likely that PlayBook and BB10, because they are based on the QNX operating system.

    If we discard Perl as a query language, then you will need to provide another option to search.  I think that unified search is an option, but you will have some work to do to use it.  The first thing you should do is find out if in fact, you can download the database on the BlackBerry.  The only available on the Blackberry database engine's SQL, so if you want the database can be exported to a SQL database, there is a chance that it would work.  I had a quick glance around the site, and I can't tell what the "database" is in the format.  Then I suggest that look you at that next.

    I hope this helps.

  • How to run VB of JSX and return a value?

    Someone knows how to do this?

    $.writeln('result:\r' + app.doScript('wsh.echo "test"', ScriptLanguage.VISUAL_BASIC));

    WSH and wscript give an error 'object required '. Same script works very well as a vbs file.

    It seems that these objects are simply not available when executing doScript, but y at - it another way to return a value?

    Justin Putney says:

    Substances. wrote:

    FWIW, to return a value from VB using doScript, you need returnValue = SomeValue at the end of your VB script.

    I know that this is the case with a Sub or Function... is that his operation at the end of a script as well?

    To answer your questions, here is an excerpt of work I have that gets the file in Excel:

    var vbs = 'Set MyXL = GetObject(, "Excel.Application")\r' +
    'Set ActiveXL = MyXL.activeworkbook\r'+
    'returnValue = ActiveXL.Path';
    var path = app.doScript(vbs,ScriptLanguage.VISUAL_BASIC);
    
  • Call a jscript vbscript script and return a value

    Hello world

    I'm trying to simplify a tedious task: every day I have to fill in an InDesign document with 48 different numbers that go into 48 blocks of text. I would like to write a script to get these numbers (the temperatures that I get in an excel file) automatically and write them in the corresponding text blocks.

    So basically I use jscript to implement a document. So I want him to call a vbscript script (since only vbscript can retrieve an excel cell value) and have it return the value to the jscript in a variable.

    So far I managed to adapt a .vbs script that retrieves the number of the cell and the poster in a box:

    Option Explicit
    Dim objApp, objWbs, objWorkbook, objSheet

    Set objApp = New
    Set objWbs = objApp.WorkBooks
    objApp.Visible = False
    Set objWorkbook = objWbs.Open ("C:\Temperature")
    Set objSheet = objWorkbook.Sheets ("Sheet1")

    MsgBox objSheet.Range ("C5"). Value

    objWorkbook.Close False
    objWbs.Close
    objApp.Quit

    ObjSheet = Nothing set
    Set objWorkbook = Nothing
    Set objWbs = Nothing
    Set objApp = Nothing

    But it is only that. I always have trouble with:

    (1) the order doScript: How can I call the jscript vbscript script?

    (2) writes the value retrieved (or table) in a variable in vbscript script

    The rest is easy: in the jscript, write the table in the corresponding text blocks.

    Hope someone can help me. Thank you very much

    Maphio M.

    When you place an Excel file in InDesign, it becomes a table. From there on, it's a simple as myFrame.tables [0] .cells [x] .silence (myFrame being a reference to the image that you placed the Excel file in).

  • Bad performance of the Script when it is called from another Script

    Hello

    I have developed a. SOUTH who calls another script via "ScriptInclude" command and I noticed a substantial decrease in performance when running in this way.

    Normally my calculation scripts runs in less then 10 sec when it is running alone.

    However, when I call the script of my. Script SOUTH it takes 2-10 minutes on the same set of data.

    It's almost as if he is running in debug mode, where I can see my channel list being filled with data that the script runs.

    What could slow this process down so much?

    With the help of DIAdem 2015 32 bit.

    OK, I used this to speed up the result and it works like a charm

    Call UIAutoRefreshSet (False)     

  • Excel: Search strings for error on a column and return a value in a 2nd

    I have a column of around 16000 entries that looks like this:

    • Z
    • Name
    • 1338823 Alberta Ulc
    • PL 1618725 Ontario Inc.
    • 2 c Costruzioni Civili Srl
    • A & D Beleggings Bk
    • A & D investment Bk
    • Aareal Holding Company mbH
    • CTAA

    I want to create a formula to search each entry to several errors, so that this example comes Pl and Bk. If it detects an error, Pl or Bk, it returns Y, if it is a N in a separate column such that it would look like this:

    • AB
    • Error
    • N
    • THERE
    • N
    • THERE
    • THERE
    • N
    • N

    Any suggestions?

    PS: have posted in this link, but it's more complicated to Research several channels in several cells in a column

    Ah it's harder, but I think that this formula it (source: http://www.excelforum.com/excel-general/905241-finding-a-value-in-one-cell-within-a-larger-text-sting-in-another-cell.html)

    Their example is in column B.  He looks at the cell to the right for what in the list in column A.  If nothing is found, it returns what she has.  Although I'm sure it can be adopted to return Y or N (or you might have even just a column more to check if B contains another type.

    Another discussion here: http://www.excelforum.com/excel-formulas-and-functions/907090-finding-a-partial-match-within-a-column.html

  • How can I return a normal dynamic object from the library (cloud symbol) to a smart object

    I only change my dynamic in Illustrator (via double klick) object when it is not in the library.

    Unfortunately, I did not know that from the beginning and now I have a few documents where all the objects are in the library and can't do em to open in Illustrator.

    When you paste from Illustrator into Photoshop, you can choose how to paste, but there is also a checkbox "add to my current library.

    Maybe this has been verified.

    But you can always change them when you open the library in Illustrator and double-click on it.

  • Javascript-based dynamic action and display the value of (!) from the selection list

    Hello

    I'm not a jQuery guru (yet).
    Can someone show me how to turn on or off an ITEM on a form based on the value display of a selection list (usually I have dynamic lists, so I don't 'know' even internal values)

    I created a simple demo in which you can (if you want to) show me how it works.

    Workspace: 6POOLRULES
    User: demo01
    Password: demo
    Application: 30851 (Drone)

    The idea is to
    * Disable/hide the "Id other Description" If the ' Id Type (display value!) is 'Passport' or 'license '.
    * activate/display the Description of the 'other' Id if the ' Id Type (display value!) is "other".


    I think that it should be dynamic action based on javascript/jQuery. But what would this jQuery selector should look like?

    Published by: bveoracle on March 29, 2012 07:28

    Published by: bveoracle on March 29, 2012 07:30

    Hello

    OK, I changed the dynamic action to use Jquery and get text from the value. The only thing I changed is in the section WHEN.

    Enjoy.

  • Stopping Subvi and returns a value of Subvi to MainVi

    Hi all

    I have a MainVI that calls a Subvi. The call in sub - VI of the MainVI is done inside a while loop. If the necessary calculation in Subvi time exceeds say 1 second I want to stop the Subvi and at the same time I want to feed a default value to the MainVI which is supposed to given by the Subvi. With the next iteration, I must call the Subvi again to accomplish my task. Please let me know how this is possible thanks in advance.

    Kind regards

    Magi

    Magi,

    The Subvi terminals will always have a value when the Subvi back.  If you do not set any other value, the value will be the default value. Add a Boolean result to the Subvi to indicate if it has expired or it terminates normally.  That test boolean in primary VI to see if the data value is valid or not.

    The questions you are asking are quite fundamental to how LabVIEW. I suggest you sepnd online some time with the tutorials on getting started with LabVIEW. What you learn, it will be over for the time spent to ask fundamental questions.

    Lynn

  • BreakFrame.jsx and return the text around objects

    Hello, I like you would break a frame. I use the BreakFrame script.

    It works when I choose "Ignore the text of not dress", but when I choose 'Object jump' with 3mm at the bottom, this copy of the script text and do not break.

    I have 2 screenshots to explain:

    without.jpg

    with.jpg

    Thanks a lot for your help!

    Hello! I hope that this script can help you:

    http://www.Adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_US&EXTID=2486 534

    Best wishes

    Sergey

  • How to change a property of objects from another VI

    Hi, I run my main vi. I have a preferences.vi window that opens.

    The preferenecs.vi opens with an invoke node.

    the preferences.vi must be able to fill the menu items of a control of the ring who lives in the main.vi

    I normally would you a property node, but as this object is in a another vi how can I communicate with her.

    I realize that a global variable seems to be able to pass values between the object and does not change the behavior of objects.

    Can someone help please!

    Thank you, Alec

    It should look like this.

  • Access to an object from another object of the same type in Java

    Suppose that we wrote a class named Class1 and objects instantiated two, named MyClass1 and MyClass2. Now we need to invoke one of the methods of MyClass2 in MyClass1, if a conditional statement is true. How is that possible? In other words how can access us MyClass2 within MyClass1?
    Thank you

    866880 wrote:
    According to suggestions I received here, I think the best way is to have a range of public and static objects instantiated of the process class (which will be the list of processes). So each process can access and access, each process can call method of some particular process (reception for example), and I think everything will be fine as a result.

    It should work, but I honestly think that the suggestion of a ProcessManager Kayaman is better.

    On the one hand, it is more oriented on the object, encapsulating the management company of the process in a single class and separating of the execution process and communication.

    The second problem I see is that you will probably end up with a bunch of static methods to view and manage your static table, for no other reason than that it is static.
    The problem with this is that you can then allow safely process your classes to be extended.

    However, perhaps the best thing is to try it and see. I'm sure that you can run, but you can work out some questions for yourself when come design changes.

    Winston

  • Create the script from another script using GUEST

    Oracle 11

    Instead of having to make a link to a different database, I want to create 2 scripts that are run from a shell script and run separately. Run Script1 in Database1 would create 2 Script using PROMPT to create the second script while entering a date of base1 to base2. I've almost got it but the problem is... Script2 using COPY FROM and I need to put a "-" at the end of each line that the GUEST takes as a literal instead of as part of the output.

    SCRIPT1:
    set pagesize 0
    set trimspool on
    set linesize 2000
    set echo off
    set verify off
    set feedback off
    set sqlblanklines on
    
    spool /home/michelle/sql_scripts/sl_dtc_copy2.sql
    
    PROMPT whenever sqlerror exit sql.sqlcode rollback
    PROMPT SET ARRAYSIZE 5000
    PROMPT SET COPYCOMMIT 20
    PROMPT set linesize 4000
    PROMPT 
    PROMPT COPY FROM {username}/{pswd}@{DB2}  TO {username}/{pswd}@{DB2}
    PROMPT CREATE SL_DTC_TMP USING SELECT DISTINCT 
    PROMPT col1, col2, col3
    PROMPT FROM dual
    PROMPT WHERE veh_data_elements_cd = 'ODO_READ'
    PROMPT and       dh.data_collected_timstm >=  
    select trunc(sysdate)-7 from dual; 
    PROMPT and       substr(vdh.vin,10,1) in ('A','B','C','D') 
    PROMPT /
    
    PROMPT spool off
    PROMPT exit
    
    spool off
    exit
    SCRIPT2 NOW:
    whenever sqlerror exit sql.sqlcode rollback
    SET ARRAYSIZE 5000
    SET COPYCOMMIT 20
    set linesize 4000
    
    COPY FROM {username}/{pswd}@{DB2}  TO {username}/{pswd}@{DB2}
    CREATE SL_DTC_TMP USING SELECT DISTINCT
    col1, col2, col3
    FROM dual
    WHERE veh_data_elements_cd = 'ODO_READ'
    and       dh.data_collected_timstm >=
    12-AUG-11
    and       substr(vdh.vin,10,1) in ('A','B','C','D')
    /
    spool off
    exit
    SCRIPT2 HOW IT SHOULD BE:
    -A [SPACE] AND a [-] at the end of each line
    -THE DATE MUST HAVE THE APOSTROPHES AND PREFERABLY AT THE END OF THE PREVIOUS LINE
    whenever sqlerror exit sql.sqlcode rollback
    SET ARRAYSIZE 5000
    SET COPYCOMMIT 20
    set linesize 4000
    
    COPY FROM {username}/{pswd}@{DB2}  TO {username}/{pswd}@{DB2} -
    CREATE SL_DTC_TMP USING SELECT DISTINCT -
    col1, col2, col3 -
    FROM dual -
    WHERE veh_data_elements_cd = 'ODO_READ' -
    and       dh.data_collected_timstm >= '12-AUG-11' -
    and       substr(vdh.vin,10,1) in ('A','B','C','D')
    /
    spool off
    exit
    Thank you

    Oops, sorry, I forgot to change the line.
    Must be double quotes to delimit the orignial:

    SELECT 'WHERE veh_data_elements_cd = ''ODO_READ'' -' from dual
    

    Kind regards
    Sylvie

Maybe you are looking for