• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Illustrator script.

Guest
Jul 04, 2017 Jul 04, 2017

Copy link to clipboard

Copied

here I have already retrieved nonNativeItems,below that JSON data is there, using this JSON data again how to re create the nonNativeItems in illustrator.

var page_details = { 

"full_name": "C%3A%5CUsers%5CAdministrator%5CAppData%5CRoaming%5CSkype%5CMy%20Skype%20Received%20Files %5C324580-1.ai",

"name": "324580-1.ai",

"page_count": 1,

"height": 15.0098402235243,

"width": 10.3500027126736,

"top": 15.0098402235243,

"left": 0,

"modification_on": "2017-07-04 09:55:51",

"creation_on": "2017-07-04 09:55:36",

"pages": [{

  "page_number": 1,

  "top": 15.0098402235243,

  "left": 0,

  "width": 10.3500027126736,

  "heigth": 15.0098402235243

}]

}

var selected_area = {

"arrSelectedArea": {

  "noe": 3,

  "xpos": 9.01471625434028,

  "ypos": 13.7328694661458,

  "height": 12.6598239474826,

  "width": 0.86028374565972,

  "pageNo": 1,

  "preview": "selectionareaexportimage1"

},

"arrCompoundPathItem": [

],

"arrImageFrames": [

],

"arrGraphItems": [

],

"arrLegacyTextItems": [

],

"arrMeshItems": [

],

"arrNonNativeItems": [{

  "xpos": 0,

  "ypos": 0.53643120659722,

  "styleJSON": "{\"controlBounds\":\"[648.0595703125,951.1435546875,712,949.1435546875]\",\"editable\":t rue,\"geometricBounds\":\"[649.0595703125,950.1435546875,711,950.1435546875]\",\"hidden\" : false,\"left\":649.0595703125,\"locked\":false,\"name\":\"\",\"opacity\":100,\"position\" : \"[649.0595703125,950.1435546875]\",\"sliced\":false,\"top\":950.1435546875,\"typename\": \ "NonNativeItem\",\"visibilityVariable\":null,\"visibleBounds\":\"[649.0595703125,950.1435 5 46875,711,950.1435546875]\",\"wrapInside\":\"\",\"wrapped\":false,\"wrapOffset\":\"\",\"a r r_position\":0}",

  "height": 0,

  "width": 0.86028374565972,

  "index": null,

  "layer": "Layer 1",

  "layer_info": "{\"name\":\"Layer 1\",\"layerName\":\"Layer 1\",\"typename\":\"Layer\",\"opacity\":100,\"visible\":true,\"dimPlacedImages\":false}",

  "groupName": "",

  "arr_position": 0

}],

"arrPluginItems": [

],

"arrRasterItems": [

],

"arrShapes": [

],

"arrSymbolItems": [

],

"arrTextFrames": [

],

"arrTextElements": [

],

"arrGroups": [

]

}

TOPICS
Scripting

Views

869

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
People's Champ ,
Jul 05, 2017 Jul 05, 2017

Copy link to clipboard

Copied

What's your point exactly ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 05, 2017 Jul 05, 2017

Copy link to clipboard

Copied

This must be one small puzzle piece of a big riddle.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 05, 2017 Jul 05, 2017

Copy link to clipboard

Copied

yes,but how do I re create non native item in illustrator using above Json data,if anybody known please do reply

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 06, 2017 Jul 06, 2017

Copy link to clipboard

Copied

LATEST

I ask myself, What are Non-Native items? I'm not sure as to what constitutes a definite description of all conditions which a non-native item meets, however, I did notice that these mysterious artifacts do make themselves present when one does ever place and embed a file which contains a gradient mesh. Although the scripting collection "Document.nonNativeItems" has no "add" method, they can be actually created within the document through importing a pre-made file, or creating a temporary file with the script. I couldn't find another method for creating these besides using a recorded action which uses the Expand menu item. This action recording is better than some other ones because it records the parameters, which is how you can guarantee that a gradient mesh is going to be produced.

The attached snippet shows you how to create non-native items.

It uses this kind of action to play the Expand command.

2017-07-06 14_01_01-.png

#target illustrator

function test(){

  if(app.documents.length == 0){

    alert("You must open a document");

    return;

  }

  app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; // turn off the alert boxes Illustrator produces

  var dummyFile = File("C:\\Users\\You\\TryToMakeNonNative.ai"); // paste in your path to the temp file you'll be making

  var dummyDoc = app.documents.add(); // make the new document

  dummyDoc.pathItems.rectangle(0, 100, 200, -200); // add one rectangle path

  dummyDoc.pathItems[0].filled = false; // set the path to have no fill

  dummyDoc.pathItems[0].selected = true; // the path is now selected in Illustrator

  dummyDoc.defaultFillColor = dummyDoc.swatches.getByName("White, Black").color; // the default stroke color is set to a gradient swatch

  app.doScript("Action 2", "Test"); // execute an action which had been recorded to expand a gradient-filled shape to a Gradient Mesh. Actions can also be loaded and played via script.

  var opts = new IllustratorSaveOptions(); // new save options, they may not be even necessary

  dummyDoc.saveAs(dummyFile, opts); // save the document in the pre-specified file path

  app.activeDocument.close(); // close the document that was just saved

 

  var doc = app.activeDocument; // we are back to original document that was open

  var testLayer = doc.layers.add(); // add a layer which can be later removed

  var newPlaced = testLayer.placedItems.add(); // place the temp file into current document. Add a placed item and set its file to the previously defined file object.

  newPlaced.file = dummyFile;

  newPlaced.embed(); //embed the temp file to have the gradient mesh be interpreted as a non-native item.

 

  var originalNonNative = doc.nonNativeItems[0]; // now we have a Non Native item to manipulate.

 

  var newNonNative;

  var yCoord = 50;

  var xCoord = -80;

  var width = 150;

  var height = 100;

  for(var i = 0;  i< 3;  i++){ // cycle through the amount of items you potentially want

    newNonNative = originalNonNative.duplicate(doc.layers[1]); // create the non-native items using the duplicate function, send them to any layer. (except the test layer created by this script!)

    newNonNative.top = yCoord -= 100;

    newNonNative.left = xCoord += 175;

    newNonNative.width = width;

    newNonNative.height = height; // change any properties here

  };

  testLayer.remove(); // clean up original open document by removing the test layer

 

};

test();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines