How to replace a block of text by an .ai file?

Hello

I am writing a javascript script Illustrator open a file's get a block of text in the layers/pageItems by its content, then replacing it by a placedItem to the incorporation of another file .ai (shape slightly).

I managed to get the pageItem and to create the placedItem in this way:

...
var item = mainGroupElement.pageItems[i];
if(item.contents == 'X') {
  $.write("X found\n");

  var walkingManFile = File("D:\\walking-man.ai");
  var walkingManItem = mainGroupElement.placedItems.add();
  walkingManItem.file = walkingManFile;
  walkingManItem.embed();
  var scaleX = item.width / walkingManItem.width * 100;
  var scaleY = item.height / walkingManItem.height * 100;
  walkingManItem.resize(scaleX, scaleY, true, false, false, false, 100, Transformation.CENTER);
  var deltaX = item.position[0] - walkingManItem.position[0];
  var deltaY = item.position[1] - walkingManItem.position[1];
  walkingManItem.translate(deltaX, deltaY, true, false, false, false);
  walkingManItem.trace();

  item.remove();
}

'element' typename is TextFrame.

'WalkingMan' form is well drawn, but not translated and resized at all. However, scaleX, scaleY, deltaX deltaY values seem to be good.

Anyone know what I'm doing wrong here?

I'd appreciate any help on this!

once incorporated, walkingManItem no longer exists (like placedItem), then the reference is lost. Get a reference to the new article created by the embed() method and proceed to your script.

Tags: Illustrator

Similar Questions

  • How to select a block of text to the Script name?

    Hello

    I have listed the text block in the code below,

    UIDRef uidreference = stories->GetNthTextModelUID(0);

    InterfacePtr<ITextModel> TheTextModel (uidreference, UseDefaultIID());

    if (TheTextModel is NOTHING)

    Break;

    IFrameList * Frames = TheTextModel->QueryFrameList();

    if (Frameworks is NOTHING)

    Break;

    AFrameUID UID = images->GetNthFrameUID(0);

    I need to select the block of text by Script name (Windows-> Utitities-> Script title).

    Please suggest the solution above the problem.

    Try,

    InterfacePtr script (content, UseDefaultIID());

    If {(script)

    ScriptLabelValue = script PMString-> GetTag();

    CAlert::WarningAlert (scriptLabelValue);

    }

  • How to make a block of text link?

    Hello

    I'm generating PDFs to an xml file by loading the xml into a predefined format.

    Code example

    cstrInddFile = marked Server.MapPath("~/Indesign_XML/DesingTemplate.indd")---contient palceholders
    cstrXMLFile = Server.MapPath("~/Indesign_XML/item.xml")
    myInDesign = CreateObject ("InDesign.Application.CS4")
    Var objDoc As InDesign.Document = CType (myInDesign.Open (cstrInddFile, False), InDesign.Document)
    objDoc.ImportXML (cstrXMLFile)

    objDoc.Export (idExportFormat.idPDFType, "D:/Test4.pdf")

    Problem: the pdf file is created but contains a page, how it will display all the data in the xml file.

    My sample xml is (I have tagged the textframe with tag story)

    < NewDataSet >
    < Story >
    < table >
    < > 34 ProductId < / ProductId >
    < > 267 ItemId < / ItemId >
    < /table >
    < / history >
    < / NewDataSet >

    Please answer someone.

    Hi Nishatry,

    After loading the XML, you must follow the following steps to resolve this problem.

    1 beginning Page numbers form XML elements.

    2. Add the number of pages required.

    3. link text frames by [myDoc var = app.activeDocument; myDoc.pages [0] .textFrames [0] .nextTextFrame = myDoc.pages [1] .textFrames [0];].

    4. place the XML to the first image [myDoc.xmlElements [0].placeXML(myDoc.pages[0].textFrames[0]);]

    5. can export to PDF

    Kind regards

    River. P

  • How to name a block of text to use textFrames.getByName?

    I think it's a pretty simple question, but I can't find examples explaining how to name the text block, so I can use the getByName feature.

    Right now I'm using a loop for to go through all the text frames and find a corresponding to a text string, but I am afraid that by random chance, that same text string will get used in a graphic and the script will change the incorrect text.

    I found this in an old NET, but couldn't find out how to apply the name to the text box. Extract the data from Excel to Illustrator javascript or vbscript

    Thanks in advance!
    CW

    Figured it out! I can quote the textframe in the layers panel so I show details for the layer that the textframe I want feeds. It defaults to the content of the textframe unless you call it in the layers panel, that's why when I tried to find a name, I wouldn't get a! Once I changed it on the layers panel, I could call him by his name! Sussed this out of one of your previous posts of Carlos, so thank you again for all that you give on these forums!

  • How to "unscrew" a block of text?

    I have a continuous text document

    Threading from end to end. I want to interrupt the threading of the text and create a separate where the thread page stops just before this page. Could someone tell me how can I do this?

    My documents are in fact part of a book. Each document contains four or five chapters with threaded continuous text flow, and there are also a few tables in each document.

    I have two reasons for wanting a thread. One is that I want each chapter to start again on a page, so that when the text changes position during formatting, it won't move the chapter cover page.

    Similarly, I want my paintings on one page, and does not move when the text in front of them moves during formatting.

    Both of these can be treated without breaking the story threaded (tables can be said to not break on several pages in the properties of the Table, and there are several ways to force the chapters to begin on a new page, the most obvious which is out of frame just before the end of a chapter).

    But, that being said, it turns out that the SplitStory script will do what you want. I don't know if it is installed automatically with CS5, or if you go shoot is out of installation disks yourself. But it is there, somewhere.

    Finally: do not use it unless you are certain that you will be the last person who will ever work in this file at 100%.

  • How to change a specific/repetitive text simultaneously in several files in folders

    I have created several models of format and drop the documents to work with where my address and phone number are displayed.  My main Editor is WordPerfect, where all files are and were created in XP Professional and Vista Ultimate.  Is there a way to specifically select these files format/templates and opt for a search and replace specific text instead of opening each file?

    Hello

    I suggest post you you query in the MSDN forum for better support.

    http://social.msdn.Microsoft.com/forums/en-us/categories

  • CS3 VB how to refer to a block of text?

    Hello

    I had a block of text in a document with a table inside. In the first cell of the table, there is another block of text with the table. How to get a reference to the first frame of text in the frame inside the cell?

    text in a cell block has a character as a parent, character has a cell as a parent, a cell table as a parent - to this place there should be the block of text just as the parent of a table, but unfortunately it is a story! so no idea how to get the block of text here?

    concerning

    innerFrame.parent.insertionPoints [0] .parentTextFrames [0]

    Substances

  • Copy the block of text in most of the pages

    Using CS4. I am designing a photo book and want to add a caption below photos on most of the pages.

    How to copy a block of text to most of the pages of the book, positioned at the same place on each page?

    Looks a very basic thing to want to do, but impossible to find some sort of obvious way to do.

    Must have something to do with master pages.

    Master page would certainly be a way to do it. Put the rframe on the master, then substitute ([Ctrl on windows] Cmd + Shift-click on the page docuent to release a Master object) to enter text or remove images or place text in the frame (without replacement) from an external file.

  • InDesign: how tilt blocks of text without distorting the text?

    I want to put in place several large blocks of copy to these requirements:

    -the basic lines of the text are at an angle on the page

    -the left and right edges of the text block are shot-on horizontal (aligned with the guides in the screenshot below)

    -the block of text can be enlarged or reduced without changing the angle of the left and right edges

    -forms of the letters themselves are not distorted

    Skew1.gif

    This screenshot shows what I'm after.

    Skew2.gif

    This screenshot shows the real bounding box for the text block.

    Skew3.gif

    This screenshot shows how the angle of the text box changes when I change its size.

    I think Illustrator is a kind of function that allows you to "zero" (reset the transformations of a grid of 90 degrees) an object after it is transformed. Not finding anything like that in InDesign. And I find no way to set a custom angle constraint that would allow me to use the direct Selection (white arrow) tool to change the height or width with confidence.

    I'd appreciate some tips! Thank you for your attention.

    I do so with the example of shooting. Tilt works the same way.

    1. draw your rectangle, I applied a text frame reference grid (textframe options)

    2. with the Selection tool or the transform tool turn the frame in one direction, you can also do this with the entrance of the value in the transform Panel, what I would recommend.

    3. now, select the direct Selection (white arrow) tool and hold the ALT key and click on the frame. Now, only the frame is selected. Turn the other way, or insert the value in the transform Panel.

    I also have another method to offer:

    1. Draw the main frame with the text tool.
    2. Draw a small box above, it must be much smaller than the main frame.
    3. Turn the small frame in the direction that where you want to go the text.
    4. Select the two images.
    5. Go to the Pathfinder > Add.

    Now, you can add text or select a text based frame reference grid. He will do the same as above. May be simpler.

  • How to remove the unwanted border around blocks of text copied and pasted

    In creating a glossary, we copied and pasted text blocks of some later entries in the glossary. Now we're getting borders around these blocks of text copied - we do not want. Original text blocks show no borders.

    How get rid of these borders?

    Thank you in advance, David Allen

    Select the images and the race set to 0 and then deselect everything and make sure that you do not have a default line for new executives.

  • How can I replace a range / the text in an XML tag

    I want to replace a piece of text in an XML tag in a text frame.

    In my input parameters, I have the In-design page number, UID text frame in this page and the name of the XML tag within this block of text

    that surrounds my old text.

    which interface/function/command can I use who can help me to replace the existing text with the input text?

    for example:

    [old text] --> [new text]

    where [] is the XML tag with the name tag1.

    After a few trails and POC, I was able to write the piece of code below.

    It detects the start and end position of the marker and based on that we can replace the text inside. It will be useful.

    InterfacePtr data (signalMgr, UseDefaultIID());

    If (data == nil)

    {

    break;

    }

    UIDRef docRef = data-> GetDocument();

    InterfacePtr doc (docRef, IID_IDOCUMENT);

    IDataBase * db = docRef.GetDataBase ();

    Get the spread

    InterfacePtr spreadList (doc, UseDefaultIID());

    Int32 spreadCount is spreadList-> GetSpreadCount();.

    for (int32 spreadIndex = 0; spreadIndex)< spreadcount;="" spreadindex++="">

    {

    Get the reference to the spread

    UIDRef spreadUIDRef (db, spreadList-> GetNthSpreadUID (spreadIndex));

    Get the object of dissemination

    InterfacePtr spread (spreadUIDRef, UseDefaultIID());

    Int32 numberOfPages = spread-> GetNumPages();

    for (int32 nPage = 0; nPage)< numberofpages;="" npage++="">

    {

    UIDList pageItemList (db);

    spread-> GetItemsOnPage (nPage, & pageItemList, kFalse, kFalse);

    Browse page items and save on the UID of executives.

    Int32 pageItemListLength = pageItemList.Length ();

    for (int32 j = 0; j)< pageitemlistlength;="" j++="">

    {

    UIDRef pageItemRef = pageItemList.GetRef (j);

    InterfacePtr frame (pageItemRef, UseDefaultIID());

    If (frame-> IsTextFrame())

    {

    Now try to get the position of the Guide to the XML tag

    TextIndex 0 = startPos, endPos = 0;

    IXMLReferenceData * xmlReferenceData = Utils()-> QueryXMLReferenceData (pageItemRef);

    REF XMLReference = xmlReferenceData-> GetReference();

    IIDXMLElement * element = REF. Instantiate();

    InterfacePtr (REF.). Instantiate());

    TagUID UID = element-> GetTagUID();

    WideString elementName = element-> GetTagString();

    for (int32 i = 0; i < element-=""> GetChildCount(); i ++)

    {

    ChildRef = element XMLReference-> GetNthChild (i);

    InterfacePtr child_element (childRef.Instantiate ());

    tagUID = child_element-> GetTagUID();

    elementName = child_element-> GetTagString();

    Int32 index = 0;

    Utils()-> GetElementMarkerPositions (child_element, & startPos and endPos);

    startPos += 1; to proceed exclude the starting tag

    }

    }

    }

    } / / Browse pages spread

    }

  • How can I get a standard text block can be found on the last page of my documents?

    How can I get a standard text block can be found on the last page of my documents without having to type in all the time? I have a mission statement with a line to the signature of the customer who I want on the last page of my bills and now I have to type every time or cut and paste a previous invoice. I already have a Master Page that contains customer information and my company at the top of each page, and I use the data merge to fill each page with the ordered items and photos etc. I would just have this mandate type block automatically appear on the last page after the last element in the data merge.

    Thank you all in advance for your help.

    Create a new master based on the one you have now and add the block, then change the master applied to the last page.

  • How can I create a series of blocks of text using the Excel list values?

    It is first of all, the first script I am trying to write from scratch. I'm completely green at the script and I picked up a few bits of ID Adobe scripting guide, but nothing has really stuck still relating to this particular goal.

    My supervisor maintains a master list of advertising space, with the name of the account, is the width of the space, and how space is the height, in an Excel sheet. These spaces can number in the hundreds, and I'm stuck manually drawing a rectangle for each space, which takes a lot of time.

    I would like to create / helped to create a script that will take these values and "magically" to draw these spaces in the form of blocks of text, with the width (in columns) and the height (in inches) defined by the values in the main list, as well as the name of each account in the subsequent text frames.

    The script didn't necessarily need to be able to pull the values directly from the Excel sheet; Can I transfer a file text if necessary, or directly in the script, values he change because I need it. A great thing (if she is not able to pull directly from an Excel sheet) which is the number of spaces a week changes, and so do the accounts and the width and height. Accordingly, it would be ideal that values of the sheet could be modified easily, in order to create a new set of spaces as necessary.

    Positioning for each space is not crucial, only the height and width. If they were all on top of each other on the same page, it is a result for me. The main idea is to not have to draw them all manually, one by one.

    For me, this looks like a command, but I hope that some experienced there Scripting Guys can help me, because I want to become experienced as well.

    Thus, the TL; DR version:

    -Script to draw a series of text blocks.

    -Size of the text boxes should be defined by the values width and height of spreadsheet Excel.

    -Text blocks must have the account name as content (from account in the Excel worksheet names).

    -Accounts, width and height changes every week in the Excel sheet, so must be relatively easy to exchange all values.

    -Width values on the Excel worksheet columns. It would be ideal that the script could turn those numbers into multiples of columns as necessary.

    -Script (optionally) can take values directly from Excel sheet.

    -Script (option) can set the fill color for the gray text frame. (If it works as I think, I could just select all the resulting images of the text myself and put them all to grey at the same time... I'm not lazy as )

    Thanks in advance to anyone who can help in any way possible, even if it's just a little push in the right direction. This script will save 1 to 2 hours of boredom every week.

    Look like the perfect thing for the InDesign scripting.

    I copy content from Excel to a text file, for a format easily read in InDesign, and there will automatically be a TAB for each 'cell', just using copy and paste.

    Here is a piece of code, perhaps you could go on with (the addition of variable to change pages and the location on the page and other things).

    The readFileLineByLine function, can be easily reused with any function using "recall". You simply tell the function what you want to be executed for each line of text that reads:

    const COLUMN_WIDTH = 2; // Define the column width in inch
    
    var pageIndex;
    var textFramesExported; // not implemented.
    
    // Add a new dokument. Set myDoc to app.activeDocument to use
    // the current document instead of creating a new one.
    var myDoc = app.documents.add();
    
    // The doSomethingWithTextRow function is called upon for every line of text read.
    readFileLineByLine('c:\\test.txt', doSomethingWithTextRow);
    
    function doSomethingWithTextRow(row){
        // We expect the text line to be TAB separated (\t = TAB). We get that from just copying the contents of an
        // excel file into a text document.
        var cells = row.split('\t');
        var companyName = cells[0]; // The Company name in the first slot of the array
        var width = COLUMN_WIDTH * cells[1];
        var height = cells[2];
    
        // Create a new text frame for every row handled
        if (pageIndex==undefined) pageIndex = 0; // Count up when you have exported a number of texts, I leave this for you to do.
        var newTextFrame = myDoc.pages[pageIndex].textFrames.add();
        newTextFrame.contents = companyName;
    
        // The text frame is created in the top left corner.
        newTextFrame.geometricBounds = [0, 0, height + ' in', width + ' in']; // Top, Left, Bottom, Right 
    
        // You might want to move the textframes to other positions, keeping track of how many you put out per page.
        newTextFrame.move( [10, 10] );
    }
    
    function readFileLineByLine(path, callbackFn){
        var myFileIn = new File(path);
        if (File.fs == 'Windows'){
            // This was probably added to recognize UTF-8 (even without its start marker?)
            myFileIn.encoding = 'UTF-8';
        }
        myFileIn.open('r');
        var myEncoding = myFileIn.encoding;
        try{
            if (!myFileIn.exists){
                throw('Missing file: ' + myFileIn.fsName)
            }
            var ln = '';
            while(!myFileIn.eof){
                // Read the lines from the file, until an empty line is found [now as a remark].
                ln = myFileIn.readln()
                // if(ln !='' && ln!='\n'){
                   // Call the function supplied as argument
                   callbackFn(ln);
                // }
            }
        }catch(e){
            alert(e);
            gCancel = true;
        }
        finally{
            myFileIn.close();
        }
    }
    

    The file in C:\ in my example was recorded in UTF-8 format and looks like this (showing hidden characters):

    Post edited by: Andreas Jansson

  • How can I move a block of text from the head of <>tag area within the &lt; body &gt; tag box?

    I am retarget approximately 2500 html files and a block of text should be moved to the head of <>mark the surface of the < body > tag. It must immediately follow the < body > tag. Here is an example: < h3 > heading < / h3 > < p > A bunch of text here, blah blah < /p >.  I find the block using a regular expression < >(.*?) < p > h3, but do not know what to do after that.

    If you just want to move the

    and

    on theand in thethe following regular expression work:

    (

    [\s\S]*?

    )([\s\S]*))

    Replace in the field, use this:

    $2$ 1

  • How to caress a block of dynamic text alive (through the appearance Panel) in Illustrator?

    How can you race (and fill) the live of the block of text in the appearance Panel?  Do not stroke the text within the text box.  I can't remember the process - this does not imply using the compound effect path/pathfinder?  JET has answered this question very well come back around 2008, I can not find the information, now.  I have both the Illustrator CS3/CS5 on Windows.

    Thank you in advance for the answers!

    As it gives him an additional loop and copy the tot to effect convert to form the line

Maybe you are looking for

  • Download firmware ios through itunes.

    If I want to download ios on my device using itunes and then I want to disconnect my device from itunes, the download process stops or it will continue?

  • Desktop HP 110-014

    I have a desktop HP 110-014.  (Pegatron) Redwood 2, Mini-ITX motherboard: 17 cm Board is far too small and has only 2 SATA ports on the card.  I would like to add 2 additional internal hard drives to give this computer more storage.    Right now, thi

  • How can I know if Toshiba real site or not?

    Is the site following a true Toshiba site? http://support.Toshiba.com/support/viewContentDetail?ContentId=2585331 The problem is, WinDVD bundled with the software "bundled" and, in the case of WinDVD, the program is Corel WinDVD for Toshiba. However,

  • Ghost images between cuts to export after the edition of interlaced images

    HelloWhen I change a few sequences in the order that are defined to be interlaced and I do some changes specific to the source, I find myself with a few images of 'ghosts' arise between cuts in export. However these ghost images are visible only in v

  • Need help with Adobe Captivate 5.5, this version is the best that I have access to the

    Recently, we loaded Adobe Captivate 5.5 on my desktop machine, we have enterprise systems I can not get the most recent 9.  Can anyone provide any support on 5.5, specifically related to the text-to-speech feature?