Current position:  Home > Default > Help - Difficulties with transate()

Help - Difficulties with transate()

Time:December 10
Advertisement
Hi, I am having some weird difficulties with the translate method. I am trying to reposition one of layers by using X and Y values from a CSV file. I tried to access the variables various ways. One was using part[5], (with 'part' as the variable'). Then tried setting variables for each value (as shown below). The dubber doesn't report any errors. The weird thing about it is that the code is supposedly executed, but the translate function is somehow 'ignored'. When I stop the script, I can see that it exists in the history panel. I get no errors during run time either. Can someone please help. I have no idea what is going on with this strange problem.
Also: I am working two documents. In my script I have it open an image that has a dpi of 266. The script duplicates the single layer of that file into a 72 dpi document and repositions the layer according to the x and y values defined in my CSV file. I tried setting both to 72 dpi, however nothing different happens. The only time something changes is if I put a constant number for x and y. By doing that, it doesn't even move to the spot it is suppose to. It repositions, but it is placed so far off the canvas.
//Duplicate unprocessed mugshot in its proper layer level, all-in-one step
app.documents[2].layers[0].duplicate(documents[1].layerSets[0].layerSets[part[3]].layerSet s[part[4]].artLayers[0], ElementPlacement.PLACEAFTER);
//Close unprocessed mugshot after duplicating
app.documents[2].close();
//Resize mugshot layer using a percentage
app.documents[1].layerSets[0].layerSets[part[3]].layerSets[part[4]].artLayers[1].resize(70 .7, 70.7, AnchorPosition.MIDDLECENTER);
//Reposition the image according to x and y values defined in CSV file
var x = part[5];
var y = part[6];
app.preferences.rulerUnits = Units.PIXELS;
app.documents[1].layerSets[0].layerSets[part[3]].layerSets[part[4]].artLayers[1].translate (x, y);
//Create mask clipping from mugshot layer
var desc3 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc3.putReference( charIDToTypeID('null'), ref2 );
executeAction( charIDToTypeID('GrpL'), desc3, DialogModes.NO );
Advertisement
I've reworked your code a bit to use intermediate variables. This makes it
easier to read (for me, at least) and also perform better.
The translate() function is really a 'moveRelative' not a 'moveAbsolute'
function. The x and y parameters are deltas from the layers current location, so
that has to be taken into account as I've done below. BTW, I may have the terms
reversed where I compute x and y. I normally make an ActionManager-type call to
Transform to do the resize and move in one step.
-X
var doc1 = app.documents[1]
var doc2 = app.documents[2];
var ls0 = doc1.layerSets[0];
var ls3 = ls0.layerSets[part[3]];
var ls4 = ls3.layerSets[part[4]];
//Duplicate unprocessed mugshot in its proper layer level, all-in-one step
doc2.layers[0].duplicate(ls4.artLayers[0], ElementPlacement.PLACEAFTER);
//Close unprocessed mugshot after duplicating
doc2.close();
var layer = ls4.artLayers[1];
//Resize mugshot layer using a percentage
layer.resize(70.7, 70.7, AnchorPosition.MIDDLECENTER);
var bnds = layer.bounds;
//Reposition the image according to x and y values defined in CSV file
var x = part[5] - bnds[0].value;
var y = part[6] - bnds[1].value;
app.preferences.rulerUnits = Units.PIXELS;
layer.translate (x, y);
//Create mask clipping from mugshot layer
var desc3 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'),
charIDToTypeID('Trgt') );
desc3.putReference( charIDToTypeID('null'), ref2 );
executeAction( charIDToTypeID('GrpL'), desc3, DialogModes.NO );
Read related articles
How difficult would it be to create something like this? 
HT204406 I am having a very difficult time with accessing my music from the cloud.  I need to have itunes open on my laptop in order for it to work.  And as soon as I close out itunes on my laptop, it gives me a warning that all users will be logged out. 
Have apple tried to make the syncing of 2 iphone on 1 imac as difficult as possible? My nokia is a doddle. I cant back up my wifes 3gs without entourage. I iponed up a seperte log in on my imace and it still says my wifes is prev synced with another itunr
Hi Apple Team, my iphone can't share files with my macbook pro. But other devices can share bluetooth files with my mac book pro. Please, kindly open up bluetooth to accept all connections from all devices. Now it becoming difficult for me to share.
I created a form, I want the email notices to go to several people. Why is this so difficult? It seems like they have to be a co-author/reader or something? I don't get it
How difficult would it be...
How difficult would it be to upgrade from Lookout 5.1 to 6.5?
How difficult would it be to implement an iMessage whitelist..?
How difficult would it be to create a bittorrent server/client?
The app icons and font on my iPhone 4 just went to massive making it difficult to even scroll how can I change it back, where do I go which menu? Thanks in advance
How do I get in touch with a live person (support) : I had an issue and were very close but all over sudden we were disconnected: so frustrating, why is it so difficult to chat with somebody ?
JDev and ADF is difficult
Why Does iTunes Make Combining Songs Into a Single Album So Difficult?
How can I make sure I only see what is on my ipad instead of everything I have in the cloud? Since upgrading to 10S 7 I see every programme I have ever bought - which makes it difficult to see the ones I want to watch now.
HT2105 Continually get a message saying "We are experiencing technical difficulties, please try later" when trying to set up allowances. Not very helpful. Any ideas. I am running the latest itunes with Windows 7 Professional.
TS3991 I was using a Numbers spreadsheet that had a lot of info on it. It started being difficult regarding inputting things on cells and then suddenly closed. I can't access it either on the iMac or in iCloud. What can I do to get the info back? Do I sto
How can I restore my playlist folders in itunes? They are there but the individual song titles aren't listed. They are only listed by album. This makes it very difficult to find songs in my playlist.  Also,when I click on music, it will not list options.
The new format on FF4 is confusing and difficult to use. Is there a setting where I can change it to show the FF3.6 format?
How can I make the background one solid color?  It is too difficult and noticeable when I use the retouch button and try to erase all the creases in my backdrop.  So, how can I have just a solid white background?

How difficult would it be to create something like this? 

2015-10-11

I'm looking to create a flash widget similar to what WoW has on their main page - http://www.worldofwarcraft.com/index.xml It needs to have images & text that could be called from a php or text file, so that it can be dynamically changed. Movies will

HT204406 I am having a very difficult time with accessing my music from the cloud.  I need to have itunes open on my laptop in order for it to work.  And as soon as I close out itunes on my laptop, it gives me a warning that all users will be logged out. 

2015-10-11

I am having a very difficult time with accessing my music from the cloud.  I need to have itunes open on my laptop in order for it to work.  And as soon as I close out itunes on my laptop, it gives me a warning that all users will be logged out.  Hel

Have apple tried to make the syncing of 2 iphone on 1 imac as difficult as possible? My nokia is a doddle. I cant back up my wifes 3gs without entourage. I iponed up a seperte log in on my imace and it still says my wifes is prev synced with another itunr

2015-10-11

By the looks of it I'm having the same problem as lots of people. Apple seem to have made the system of syncing and backing  up 2 iphones as difficult as possible. I have just bought an iphone4 and synced it to my imac. I now have my wife's apps and

Hi Apple Team, my iphone can't share files with my macbook pro. But other devices can share bluetooth files with my mac book pro. Please, kindly open up bluetooth to accept all connections from all devices. Now it becoming difficult for me to share.

2015-10-11

Hi Apple Team, my iphone can't share bluetooth files with my macbook pro. But other devices can share bluetooth files with my mac book pro. Please, kindly open up bluetooth to accept all connections from all devices. Now it difficult for me to share

I created a form, I want the email notices to go to several people. Why is this so difficult? It seems like they have to be a co-author/reader or something? I don't get it

2015-10-11

I created a form, I want the email notices to go to several people. Why is this so difficult? It seems like they have to be a co-author/reader or something? I don't get itThis is crazy! I paid for this service to make it easier to create forms for a

How difficult would it be...

2015-10-11

...for me to remove the harddrive from my g4, turn it into an external harddrive, and attach it to a mini? We had a power outage, which fried our power source. Our harddrive should be just fine, but since we have a "vintage" machine (G4 from '97

How difficult would it be to upgrade from Lookout 5.1 to 6.5?

2015-10-11

Hello, I was told that Lookout 6.5 works with Windows 7. Before I purchase 6.5 I need to know how difficult it will be to move from 5.1 to 6.5. Has anyone done this move? If I am going to have to redraw, or do numerous changes to the Database then I

How difficult would it be to implement an iMessage whitelist..?

2015-10-11

iMessage spam is a really big problem to me and my family members.  And getting worse by the week. Blocking individual senders is ludicrously ineffective and Apple seems to be reluctant to allow us to block entire domains (which would really help). S

How difficult would it be to create a bittorrent server/client?

2015-10-11

I was thinking about creating a program that would use bittorrent to upload/download. I was wondering has someone created a package to make this easy? How difficult would it be to create something like this?The difficulty and time to do it depends on

The app icons and font on my iPhone 4 just went to massive making it difficult to even scroll how can I change it back, where do I go which menu? Thanks in advance

2015-10-11

The app icons and font on my iPhone 4 just went to massive making it difficult to even scroll how can I change it back, where do I go which menu? Thanks in advanceNext time you accidentally use 3 fingers it will zoom again. Unless you need the featur

How do I get in touch with a live person (support) : I had an issue and were very close but all over sudden we were disconnected: so frustrating, why is it so difficult to chat with somebody ?

2015-10-11

where can I get back in that chatroom, please ? I don't find it back I'm here for almost 1,5 hour, and still no solution Aquib: Hello. Welcome to Adobe Technical Support. Aquib: Hi,annemie. annemie: Er is geen programma ingesteld om de URL 'aam://SAP

JDev and ADF is difficult

2015-10-11

As a new user to ADF I am finding ADF and JDev a little discouraging and hard to use. I did a search on how to improve jdev's performance and found a lot of useful tips and tricks to use, but I pose the question. Shouldn't it just work out of the box

Why Does iTunes Make Combining Songs Into a Single Album So Difficult?

2015-10-11

Can anyone explain, or refer me to a website, that explains and lists in a "1,2,3" manner the illogic of the iTunes "get info" panes and why iTunes splits, combines and erases data depending upon what you put in the "get info"

How can I make sure I only see what is on my ipad instead of everything I have in the cloud? Since upgrading to 10S 7 I see every programme I have ever bought - which makes it difficult to see the ones I want to watch now.

2015-10-11

I buy programmes etc for the whole family and it used to be that on each ipad I could only see the icons for the programme I chose to sync to the ipd/ipod etc. However, now every programme I have ever bough is dospayed which makes it difficult for fa

HT2105 Continually get a message saying "We are experiencing technical difficulties, please try later" when trying to set up allowances. Not very helpful. Any ideas. I am running the latest itunes with Windows 7 Professional.

2015-10-11

Continually get a message saying "We are experiencing technical difficulties, please try later" when trying to set up allowances. Not very helpful. Any ideas. I am running the latest itunes with Windows 7 Professional.Not a solution yet, but rec

TS3991 I was using a Numbers spreadsheet that had a lot of info on it. It started being difficult regarding inputting things on cells and then suddenly closed. I can't access it either on the iMac or in iCloud. What can I do to get the info back? Do I sto

2015-10-11

Can anyone help me get all my info that is locked in a NUmbers spreadsheet? I was inputting a lot of info when it started being a little difficult, and then it closed down on me. It now will not open telling me that there is no index in it!! I need t

How can I restore my playlist folders in itunes? They are there but the individual song titles aren't listed. They are only listed by album. This makes it very difficult to find songs in my playlist.  Also,when I click on music, it will not list options.

2015-10-11

My itunes account is messed up. How can I restore my playlist folders in itunes? The list's are there but the individual song titles aren't. They are only listed by album. I can only see the song titles as they are played at the top of my itunes. Thi

The new format on FF4 is confusing and difficult to use. Is there a setting where I can change it to show the FF3.6 format?

2015-10-11

Myself and several of my friends were discussing the new Firefox layout for Firefox 4.0, and we find it difficult to use. We would like to have the option of using the new Firefox with the old 3.8 layout. That would make it much easier to use. One of

How can I make the background one solid color?  It is too difficult and noticeable when I use the retouch button and try to erase all the creases in my backdrop.  So, how can I have just a solid white background?

2015-10-11

How can I make the background one solid color?  It is too difficult and noticeable when I use the retouch button and try to erase all the creases in my backdrop.  So, how can I have just a solid white background?When talking about a specific image po