Skip navigation
Currently Being Moderated

Import PSD to AI layer

Sep 8, 2012 9:18 AM

Tags: #illustrator #import #learning_scripting #javacsript #scripting #illustrator_cs5 #illustrator_cs6

I am new to scripting in Illustrator.

I am trying to import PSD files into an AI layer.

So far this is my solution.

 

var TRGdoc = app.documents.add(DocumentColorSpace.RGB, "1920", "1080");

 

var onFile = File( '~/Desktop/jpeger/illDanceREFon_00642.psd' );

var REFon = app.open(onFile);

var LAYon = REFon.layers[0];

var LAYstuffon = LAYon.pageItems[0];

LAYstuffon.selected = true;

app.copy();

TRGdoc.activate();

var TRGlayer = TRGdoc.layers[0];

TRGlayer.selected = true;

app.paste();

 

It works most of the time but sometimes it hangs up on the paste.  It feels sloppy.

Just wondering if a more elegant solution exists.

 

Thanks for looking!

 
Replies
  • Currently Being Moderated
    Sep 8, 2012 10:23 AM   in reply to lilsmokie

    You are opening the *.psd file then using the clipboard to copy to another doc? Why don't you just place the *.psd, move it where ever then embed if you want?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 8, 2012 11:39 AM   in reply to lilsmokie

    Untested but placedItems.add() does not have any parameters for your file object… You can set the property after creation… Like so…

     

    var TRGdoc = app.documents.add(DocumentColorSpace.RGB, "1920", "1080");
    var onFile = File( '~/Desktop/jpeger/illDanceREFon_00642.psd' );
    var poop = TRGdoc.placedItems.add();
    poop.file = onFile;
    //poop.move(TRGdoc.layers[0], ElementPlacement.INSIDE); should be here by default?
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points