Giter VIP home page Giter VIP logo

illustrator-scripting-python's People

Contributors

lohriialo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

illustrator-scripting-python's Issues

How to inspect AI object properties?

Hey there,
first of all let me thank you for sharing this, along with ID and PS this information is extremely valuable!

I'm still a novice with Python, so maybe I'm asking something obvious and probably unrelated to this, but basically how can I inspect AI object properties and methods?

Picking from your Hello World example:

app = GetActiveObject("Illustrator.Application")
docRef = app.Documents.Add()

Doing a basic dir returns methods from the win32com.client.GetActiveObject class, so how can I get the details of the app.Documents object for example?

I don't know much (nothing probably is more appropriate) about the whole .NET/COM structure, Googling around I found that is not something easy to achieve, so I was wondering also what is your workflow and dev setup for scripting.

Thank you!

Images and Colours

How would I go about adding images using this?
Also, when I attempt to add a fillColor (on a rectangle like you made in the hello world tutorial) I get the error: TypeError: Cannot put <win32com.gen_py.None.CMYKColor> in VARIANT would you be able to provide examples for these things?
Cheers

Can't save file as PDF due to COM variant conversion error

Hello,

First off, thank you so much for working on this project and enabling us to do so much more with Illustrator outside of its Javascript engine. I am using it to create a script to assist with sticker sheet creation and other large format printing needs.

I have had issues when trying to send certain parameters to Illustrator through a method call. Most variable types work, but when I try to send an object, I get this error:

doc.SaveAs(infotech, saveOpts)
File "c:\Users\USERDIRECTORY\Documents\PythonLearning\IllustratorLibrary21.py", line 2017, in SaveAs
return self._oleobj_.InvokeTypes(1398161747, LCID, 1, (24, 0), ((8, 1), (12, 17)),SaveIn
TypeError: Objects of type 'type' can not be converted to a COM VARIANT`

"infotech" is a variable that I have my destination path saved to. This is how I build "saveOpts":

 saveOpts = ai.PDFSaveOptions
 saveOpts.Compatibility = 7
 saveOpts.GenerateThumbnails = False
 saveOpts.PreserveEditability = False

I cannot save the document to a PDF because I cannot send the PDFSaveOptions parameter without receiving this error. I have done my own research into the error and honestly a lot of it is over my head, but I believe I understand the basics of a COM environment and how Python may need to convert variables to different types in order to work with other software.

Some things I've found:
Any object or variable created via the illustrator-scripting-python API cannot be passed to Illustrator. For instance, to add a spot color swatch to the document and save it as a variable, you cannot use the API's method Swatches.Add(), as this will give you the same error I posted above. Instead, you must do App.ActiveDocument.Spots.Add(), then set the Name attribute of that spot, then loop through ActiveDocument.Swatches to find the name and save THAT result to a variable.

Example:

if swatchExists == False:

    perfCut = doc.Spots.Add()
    perfCut.Name = 'PerfCutContour'
    perfCut.ColorType = 2
    perfCut.Color.Black = 0
    perfCut.Color.Magenta = 0
    perfCut.Color.Cyan = 100
    perfCut.Color.Yellow = 100

    for c in doc.Swatches :
        if c.Name == 'PerfCutContour' :
            perfCutContour = c'

Originally I was trying to use Swatches.Add(), then set the "Spot" attribute of that swatch to the spot I've created in the example code above. Trying to set the Spot attribute never worked and only gave me the same conversion error that I posted at the top.

Other notes:

  • I can save the file using doc.Save() but the only option with that is an AI file. We need PDFs specifically because our print software won't run anything else.
  • I will update this post if I find solutions or any more information

Update 9/22/21

I was able to work around this problem by simply running a Javascript file from my Python script. I wanted to avoid JS as much as possible with this project but I think this solution is fine and has been working great for me in a production environment for almost 3 weeks. When ready to save, I use the code:

doc = app.ActiveDocument
destination = C:/Whatever/Filename/ToSaveTo.pdf
arguments = [doc, destination]
app.DoJavaScriptFile(jsSave, arguments)

As for the "jsSave" file, that is a .js file in the same directory as my script. The JS is as follows:

doc = arguments[0]
destination = arguments[1]

function saveAndClose(doc, dest) {
    var saveName = new File(dest);
    saveOpts = new PDFSaveOptions();
    saveOpts.compatibility = PDFCompatibility.ACROBAT8;
    saveOpts.generateThumbnails = false;
    saveOpts.preserveEditability = false;
    doc.saveAs(saveName, saveOpts);
    doc.close();
}

saveAndClose(doc, destination)

"Self" property explanation

Hey, I stumbled upon your repo and tried to use it in a project. (https://github.com/SaadBazaz/auto-corona-graphics-generator) However, I need help in Exporting.
I'm using the direct Illustrator COM but there's no reference on how to Export.

In the API you've provided as well (illustrator_2020.py), there's a function:
Document.Export( )
But it contains an argument called "self" which I don't understand.

Any guidance would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.