Copy link to clipboard
Copied
Hello everyone,
I'm currently working on automating tasks in Adobe Illustrator using Python's win32com.client library. I've successfully connected to the running Illustrator application using:
python
app = win32com.client.GetActiveObject("Illustrator.Application")
My goal is to create a new document with a specific ruler unit (e.g., Millimeters) at the time of creation using app.Documents.Add().
However, I'm facing a challenge:
1. Unknown Parameter List: I cannot find comprehensive, up-to-date documentation that clearly lists all the parameters and their corresponding values for the Add() method when using win32com. The official scripting guide primarily covers ExtendScript (JavaScript), which has different syntax.
2. Parameter Value Discrepancy: I suspect that the parameter constants used in win32com might differ from those used in JavaScript (JSX). For example, in JSX, you might use app.documents.add().rulerUnits = Units.MILLIMETERS;, but I need to know what integer value or constant name corresponds to "Millimeters" in the win32com Add() call.
Specifically, I'm trying to understand how to set the unit correctly within this call:
python
doc = app.Documents.Add(?, ?, ?, ?, ?, ?, ?, ?)
What are the correct values to pass for the Units parameter? Is it 1 for Millimeters, like some internal file data suggests? And what about the other optional parameters?
I've tried searching online and looking at the win32com.client.constants module, but haven't found a definitive answer.
Could anyone who has experience with Python COM automation for Illustrator please help clarify the exact parameters and their values for Documents.Add()? Any guidance or code examples would be greatly appreciated!
Thank you in advance for your help and expertise!
good to hear you found out you can execute javascript via COM
go to the Developer Console to download the official vbscript reference. Sign in with your adobe id
https://developer.adobe.com/console/80148/servicesandapis/ai
Copy link to clipboard
Copied
@ob_default46715138 because it's been a few days since you posted, you may want to try a 'Reddit Illustrator forum'
Copy link to clipboard
Copied
I think the parameters should be the same as vbscript but don't quote me on this
however, documents.Add() doesn't take a Units paramenter, AddDocument() function does
AddDocument
(startupPreset as String
[, presetSettings as DocumentPreset]
[, showOptionsDialog as Boolean)
DocumentPreset Object has a lot of properties you can set, including DocumentUnits
aiUnitsCM = 3
aiUnitsInches = 2
aiUnitsMM = 6
aiUnitsPicas = 5
aiUnitsPoints = 4
aiUnitsQ = 7
aiUnitsPixels = 8
aiUnitsUnknown = 1
check the vbscript Reference for more info
Copy link to clipboard
Copied
Thank you for your help.
Copy link to clipboard
Copied
good to hear you found out you can execute javascript via COM
go to the Developer Console to download the official vbscript reference. Sign in with your adobe id
https://developer.adobe.com/console/80148/servicesandapis/ai
Find more inspiration, events, and resources on the new Adobe Community
Explore Now