質問

I am trying to work out how to define a set of properties in one style template on an illustrator file them import these properties to use in another. For example I have a pink rectangle named as 'outerbox' that is 50mm x 100mm saved on an illustrator file called style1.ai

I would use extend script to draw a box called say 'box1' then load the width and height from the style1 file and apply to the dynamically drawn rectangle. I can see that I can use graph styles and stylesheets to apply font weights etc.

I need to do this as I will be using a script to draw a series of objects that will have to be drawn to a series of varied shapes and sizes that will change over time. It would be better if I could set up a set of visual templates that could be accessed by other designers rather than have a lot of code to wade through. Tried looking for this but the nearest I could find was the object watch function. Its the accessing the properties from an external file I can't find

Thanks Bob

役に立ちましたか?

解決

It sounds like you want to have a library of master visual files. I did something similar where I created AI template files for things that I needed to programmatically reference. It shouldn't be any more complicated than opening the file and making it the active document to work with and then referencing the named shape as a child of the active document. After you've harvested the attributes you want you could leave the file open for further references, or choose to programmatically close the file.

I would say though that depending on how frequently this script is run, and how many shapes you are thinking of have as visual masters, you might consider it to be more efficient to create one visual master document and continually reference it rather than have one file per visual master.

var visualMaster = File(app.path + TemplateFolder + TemplateName); 
if (visualMaster!= null && visualMaster.exists)  {
    illustrator.open(visualMaster);
    var myDoc = app.activeDocument;  // Get a reference to the newly created document

    // manipulate your object based on attributes in the opened visual master file
}
else  {
    alert(TemplateName + " not found.");
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top