[Pythonmac-SIG] Making py-appscript classes for Adobe Illustrator
has
hengist.podd at virgin.net
Fri Jan 18 21:57:10 CET 2008
grzessnik wrote:
> I'm py-appscript newbie and I'm trying to write a script for Adobe
> Illustrator.
> [...]
> class Rectangle(Obiekt):
> def __init__(self, kreator, wspolrzedne=[0,0,100,100],
> nazwa='figura'):
> self.obiekt = kreator.make(new = k.rectangle,
> with_properties = {k.name: nazwa, k.bounds: wspolrzedne})
> self.name = nazwa
>
> rect1 = Rectangle(mojDokument, [200,200, 100, 100])
> rect2 = Rectangle(mojDokument, [100,200, 200, 100], 'prostokat02')
>
> both objects reference to the same path item
> app(u'/Applications/Adobe Illustrator CS2/Adobe
> Illustrator.app').documents[1].layers[1].path_items[1]
> app(u'/Applications/Adobe Illustrator CS2/Adobe
> Illustrator.app').documents[1].layers[1].path_items[1]
>
> I suppose, that is because, new objects are always numbered at 1.
Yeah, Illustrator-returned references are pretty fragile, although
it's less of an issue if you create an object then apply all of your
desired transformations to it before you create the next one.
> Can I refere to my created objects via names (self.name)?
IIRC, objects aren't named by default; however you could generate your
own unique names easily enough. Assign each object a unique name via
the 'make' command's 'with properties' parameter, and then use that
name in any future references you construct yourself.
HTH
has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
More information about the Pythonmac-SIG
mailing list