Drea
April 21, 2009, 10:09am
1
I’m trying to load two tgas, copy the rgb from the first and paste into the alpha channel of the second but I’m getting “Attribute Error: .Paste”.
The images load fine and I can ctrl-v manually into the alpha channel after the exception, so the copy was successful. Here’s what I’ve got so far…
def processTexs(app, tex1, tex2):
tex1Tex = app.Open(tex1)
tex2Tex = app.Open(tex2)
app.ActiveDocument = text1Tex
tex1Tex.ArtLayers["Background"].Copy()
tex2Tex.Channels["Alpha 1"].Paste()
Help!!! :laugh:
Cheers,
Drea
Hmm, if I remember right at all, you need an argument in the .Paste() method to say whether it’s into the current selection or not.
tex2Tex.Channels[“Alpha 1”].Paste(true)
I have my code at home so I’ll check later tonight.
I also am using VB or C# – pardon if my “code accent” is off!
Drea
April 21, 2009, 3:07pm
4
Thanks Alex, that makes sense (as much sense as it ever does ).
I’m at home now and the code’s at work, so I’ll give it a try in the morning.
Cheers,
Drea
Drea
April 22, 2009, 3:09am
5
Hmm, that’s not working either.
I thought that maybe Channels doesn’t support Paste, but this fails too.
tex1Tex.ArtLayers["Background"].Copy()
tex2Tex.ArtLayers["Background"].Paste()
Do I need a selection to paste into perhaps?
whw
April 22, 2009, 3:18am
6
I was playing around with Python (I imported the 2.6 or whatever release into Maya) a while back and came up with this. It copies the RGB from doc1 and pastes it into doc2, creates an alpha channel and pastes into that too. I never took my tool further than this tho :D:
import win32com.client
psApp = win32com.client.Dispatch("Photoshop.Application")
doc1 = psApp.Open(r"C:\chisel.bmp")
doc2 = psApp.Open(r"C:\bandanas.jpg")
psApp.ActiveDocument = doc1
layer1 = doc1.ArtLayers[0]
copyOfLayer = layer1.Copy()
psApp.ActiveDocument = doc2
doc2.Paste()
moo = doc2.Channels.Add() #add alpha
doc2.Paste(copyOfLayer)
The key thing is to change the ActiveDocument.
Drea
April 22, 2009, 5:35am
7
Seems it’s the active layer too.
def processTexs(app, tex1, tex2):
tex1Tex = app.Open(tex1)
tex2Tex = app.Open(tex2)
app.ActiveDocument = text1Tex
tex1Tex.ArtLayers["Background"].Copy()
app.ActiveDocument = tex2Tex
theChannels = [tex2Tex.channels["Alpha 1"]]
tex2Tex.activeChannels = theChannels
tex2Tex.Paste()
I’m guess it works like this because scripting is really driving the event system without having to press buttons. Or it might be something else.
Thanks for the help :D:
system
June 6, 2009, 12:01am
8
Popular posts you write with ah! Top of youNSK NSK NSK