COM Automation Python: Creating documents for a specified unit
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!
