Sg2.9
reffering to document by name
Recent RSS
reffering to document by name
Date:  6. March 2006, 16:13

I'm working on a tool to draw tiles, and I was thinking it would be nice to be able to have a seperate document for the palette.

But as far as I can see you can only refer to a document by it's index.. Does anyone know if you can also refer to it by name somehow?

If it isn't possible, I guess I could just check for layer names in every document to find the right one.. But if there's a cleaner way to do it...

Re: reffering to document by name
Date:  7. March 2006, 14:05

Yeah, but there doesn't seem to be a title property to check..

With layers you can see a layer by talking to activeDocument.layers["layername"], doesn't work with documents though..

I tried documents["documentname"], but it returns undefined..

Re: reffering to document by name
From:  Jürg Lehni
Date:  7. March 2006, 16:40

This doesn't work at the moment. I'll look into it to see how easy it would be to implement. Until then, you might use a local lookup table:

var docs = {};
docs[doc.file.name] = doc;
...

I haven't tried the above code, but it might work ;)

Re: reffering to document by name
Date:  7. March 2006, 16:46

Just what I was looking for! Thanks Juerg

Re: reffering to document by name
Date:  7. March 2006, 18:12

I wrote a bit of code to check through the documents and find one that matches the right file name.

When I have the document I'm checking for as the active document, it prints out the correct layers.length.

When I have another document as the active document, it returns the layers.length of that document and not the one I checked for. But it does print out the correct file.name! How weird is that??

Some sample code, change the file.name to something else to try it out.

for(i=0; i<documents.length; i++){
	if(documents[i].file.name=="tile_palette.ai"){
		var pdoc=documents[i];
	}
}

print(pdoc.layers.length)
print(pdoc.file.name)
Re: reffering to document by name
From:  Jürg Lehni
Date:  8. March 2006, 02:33

Welcome to Adobe's SDK weirdness, that I try to hide behind a friendly object oriented layer as good as I can.

I'll fix it and upload a new version soon.

Thanks for reporting it.

Re: reffering to document by name
Date:  8. March 2006, 10:56

Thanks!

I'm just wondering if it would be possible after it's fixed to clone an object and then append to a different document.. Wait and see I guess

Re: reffering to document by name
From:  Jürg Lehni
Date:  16. March 2006, 18:30

It's fixed now in CVS. New beta packages will follow soon.

Re: reffering to document by name
Date:  19. March 2006, 00:28

thanks very much!

Re: reffering to document by name
From:  
Date:  22. March 2006, 11:36

The scriptographer update works, but what I wanted to use it for doesn't:

Appending between documents doesn't seem to work..

for(i=0; i<documents.length; i++){ 
   if(documents[i].file.name=="tile_palette.ai"){ 
      var pdoc=documents[i]; 
   } 
} 
placeholder=pdoc.layers.getLayer("str").children[0].clone();

print(activeDocument.activeLayer.append(placeholder))

The print returns false when I'm in a document other then tile_palette.ai, but it returns true (i.e. it works) when I'm in the tile_palette.ai document.

Anyone have an idea how to accomplish this in another way?

Re: reffering to document by name
From:  Jürg Lehni
Date:  22. March 2006, 13:37

I think Illustartor's internal command does not support multiple documents for this. I will handle the case where the two art objects do not share the document seperately.

It's good to know about this, because this is exactly the kind of weirdness present in Adobe's SDK that I want to iron out in my plugin.

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Lissajous 10.01.13