Rotate a 3D object on Z Axis with no re-scaling

Discussion of Automation, Image Workflow and Raw Image Workflow

Moderators: xbytor, DavideBarranca, Paul MR

Limey

Rotate a 3D object on Z Axis with no re-scaling

Postby Limey » Wed Dec 12, 2012 8:45 pm

Hi folks...
I am getting into new territory that involves working with 3D objects. I have an action that rasterizes a cylinder with texture and saves it as a file. It then backs up (snapshot) and rotates the 3D object to the left about 60 degrees, rasterizes and saves as a second file. It does the same thing for a third file after centering but to the right this time. It works on the file that it was set up on... but

It seems that although I simply changed the z angle from 0 to 300 and then from 0 to 60 the action is recording the object's X,Y,Z position, X,Y,Z angle and object X,Y and Z scale.

When I use the action on another image (object) it is rescaling and positioning that object and not just rotating it. Is there a way that I can leave whatever the X,Y,Z properties are for an object alone and just change the Z angle.

I thought I would look at what Script Listener was seeing and it's shown below.

Code: Select allvar idsetthreeDObjectPosition = stringIDToTypeID( "set3DObjectPosition" );
    var desc9 = new ActionDescriptor();
    var idkeythreeDCurrentPosition = stringIDToTypeID( "key3DCurrentPosition" );
        var desc10 = new ActionDescriptor();
        var idkeythreeDXPos = stringIDToTypeID( "key3DXPos" );
        desc10.putDouble( idkeythreeDXPos, 0.551146 );
        var idkeythreeDYPos = stringIDToTypeID( "key3DYPos" );
        desc10.putDouble( idkeythreeDYPos, -0.618277 );
        var idkeythreeDZPos = stringIDToTypeID( "key3DZPos" );
        desc10.putDouble( idkeythreeDZPos, 0.635015 );
        var idkeythreeDXAngle = stringIDToTypeID( "key3DXAngle" );
        desc10.putDouble( idkeythreeDXAngle, 0.000005 );
        var idkeythreeDYAngle = stringIDToTypeID( "key3DYAngle" );
        desc10.putDouble( idkeythreeDYAngle, 0.000000 );
        var idkeythreeDZAngle = stringIDToTypeID( "key3DZAngle" );
        desc10.putDouble( idkeythreeDZAngle, 300.000000 );
    var idkeythreeDCurrentPosition = stringIDToTypeID( "key3DCurrentPosition" );
    desc9.putObject( idkeythreeDCurrentPosition, idkeythreeDCurrentPosition, desc10 );
    var idkeythreeDCurrentObjectXScale = stringIDToTypeID( "key3DCurrentObjectXScale" );
    desc9.putDouble( idkeythreeDCurrentObjectXScale, 1.754662 );
    var idkeythreeDCurrentObjectYScale = stringIDToTypeID( "key3DCurrentObjectYScale" );
    desc9.putDouble( idkeythreeDCurrentObjectYScale, 1.737562 );
    var idkeythreeDCurrentObjectZScale = stringIDToTypeID( "key3DCurrentObjectZScale" );
    desc9.putDouble( idkeythreeDCurrentObjectZScale, 1.049131 );
executeAction( idsetthreeDObjectPosition, desc9, DialogModes.NO );

Looks like the Variable and change I am looking for are in the following lines:
Code: Select all       var idkeythreeDZAngle = stringIDToTypeID( "key3DZAngle" );
        desc10.putDouble( idkeythreeDZAngle, 300.000000 );

The other Variables would have to be the same as any current 3D object that the script would run on and not change the values to those of the original object used to create the action.

I still dream of the day I will be able till do this stuff myself (I'm getting there, albeit slowly) but until then... Thank heavens for PS-Scripts and it's members!

Many thanks,
Limey (Paul)

Mike Hale

Rotate a 3D object on Z Axis with no re-scaling

Postby Mike Hale » Thu Dec 13, 2012 12:16 am

I don't do much 3D and I have not tried this but from my experience working with Action Manager I would say that what you need to do is find a way to get the current settings. My guess is they are buried somewhere in the layer's descriptor. So you would get the layer descriptor then look for any 3D key IDs. Keep drilling down until you find the descriptor you need.

Once you have those settings it would be easy to change just the one(s) you want and leave the others unchanged.

I will be glad to help if you can upload a sample doc. That way I will have a 3D layer created you to explore.

Limey

Rotate a 3D object on Z Axis with no re-scaling

Postby Limey » Thu Dec 13, 2012 4:48 pm

Thanks Mike,
I have sent it to you via E-mail.

Paul (Limey)

Mike Hale

Rotate a 3D object on Z Axis with no re-scaling

Postby Mike Hale » Thu Dec 13, 2012 8:18 pm

I am going to reply here instead of by email as there may be someone else how would like to see how this is done. Even if they are not interested in 3D the same techniques can be used to find key for other objects like layer effects.

First I find it helpful to clean up the scriptlistener code. For me this is easier to read.
Code: Select allvar desc9 = new ActionDescriptor();
   var desc10 = new ActionDescriptor();
      desc10.putDouble( stringIDToTypeID( "key3DXPos" ), 0.551146 );
      desc10.putDouble( stringIDToTypeID( "key3DYPos" ), -0.618277 );
      desc10.putDouble( stringIDToTypeID( "key3DZPos" ), 0.635015 );
      desc10.putDouble( stringIDToTypeID( "key3DXAngle" ), 0.000005 );
      desc10.putDouble( stringIDToTypeID( "key3DYAngle" ), 0.000000 );
      desc10.putDouble( stringIDToTypeID( "key3DZAngle" ), 300.000000 );
   desc9.putObject( stringIDToTypeID( "key3DCurrentPosition" ), stringIDToTypeID( "key3DCurrentPosition" ), desc10 );
   desc9.putDouble( stringIDToTypeID( "key3DCurrentObjectXScale" ), 1.754662 );
   desc9.putDouble( stringIDToTypeID( "key3DCurrentObjectYScale" ), 1.737562 );
   desc9.putDouble( stringIDToTypeID( "key3DCurrentObjectZScale" ), 1.049131 );
executeAction( stringIDToTypeID( "set3DObjectPosition" ), desc9, DialogModes.NO );
Now that I have a clearer idea of the keys needed it's time to see if I can find them. To do that we need either Xbytor's getterDemo or the code below. getterDemo outputs a lot more detail and can work with multiple classes/objects. I find my version more interactive. Here is the basic starting code to get a layer's descriptor. So with a 3D layer selected in Photoshop, run the following in ESKT.
Code: Select allfunction getDescriptor( psClass, psKey ){
   var ref;
   ref = new ActionReference();
   if( psKey != undefined ) ref.putProperty( charIDToTypeID( "Prpr" ), psKey );
   ref.putEnumerated( psClass , charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
   return psKey != undefined ? executeActionGet(ref).getObjectValue( psKey ):executeActionGet(ref);
};

var desc = getDescriptor(charIDToTypeID("Lyr ") );
$.writeln( desc );

if(desc.typename == 'ActionReference'){
   var c = desc.count;
   for(var i=0;i<c;i++){ //enumerate reference. use getForm() to determine which get method to use
     $.writeln('Key '+zeroPad( i+1, 2 )+' = '+desc.getReference(i).getIndex());
   }
}

if(desc.typename == 'ActionList'){
   var c = desc.count;
   for(var i=0;i<c;i++){ //enumerate list
     $.writeln('Key '+zeroPad( i+1, 2 )+' = '+desc.getType(i))
   }
}
if(desc.typename == 'ActionDescriptor'){
   var c = desc.count;
   for(var i=0;i<c;i++){ //enumerate descriptor's keys
     $.writeln('Key '+zeroPad( i+1, 2 )+' = '+IDTz(desc.getKey(i))+' : '+desc.getType(desc.getKey(i)))
   }
}
function IDTz(id){
   var isCharID = false;
   try {
      if( new String( id ).length == 10 ) {
         isCharID = true;
         var charID = '"'+typeIDToCharID( id )+'"';
         var stringID = '"'+typeIDToStringID( id )+'"';
         if( stringID.length <=2 ) {
            stringID = '  NA   ';
         }else{
            while( stringID.length < 25 ){
            stringID += ' ';
            }
         }
      }else{
         var charID = ' NA  ';
         var stringID = '"'+typeIDToStringID( id )+'"';
         while( stringID.length < 25 ){
            stringID += ' ';
         }
      }
   }catch(e){}
   return charID+' | '+stringID;
}
function zeroPad(num,pad) {
     var z = Math.pow(10,Number(pad))
     return num <= z ? ((Number( num) + z).toString().substr(1)): num
}
You should see something like this in the ESTK console. This output is from Paul's sample doc with CS5 so the results may be different with a different version or document.
Code: Select all[ActionDescriptor]
Key 01 = "Nm  " | "name"                    : DescValueType.STRINGTYPE
Key 02 = "Clr " | "color"                   : DescValueType.ENUMERATEDTYPE
Key 03 = "Vsbl" | "visible"                 : DescValueType.BOOLEANTYPE
Key 04 = "Md  " | "mode"                    : DescValueType.ENUMERATEDTYPE
Key 05 = "Opct" | "opacity"                 : DescValueType.INTEGERTYPE
Key 06 = "LyrI" | "layerID"                 : DescValueType.INTEGERTYPE
Key 07 = "ItmI" | "itemIndex"               : DescValueType.INTEGERTYPE
Key 08 = "Cnt " | "count"                   : DescValueType.INTEGERTYPE
Key 09 = "PrsT" | "preserveTransparency"    : DescValueType.BOOLEANTYPE
Key 10 = "lfxv" | "layerFXVisible"          : DescValueType.BOOLEANTYPE
Key 11 = "gblA" | "globalAngle"             : DescValueType.INTEGERTYPE
Key 12 = "Bckg" | "background"              : DescValueType.BOOLEANTYPE
Key 13 =  NA   | "layerSection"            : DescValueType.ENUMERATEDTYPE
Key 14 =  NA   | "layerLocking"            : DescValueType.OBJECTTYPE
Key 15 = "Grup" | "group"                   : DescValueType.BOOLEANTYPE
Key 16 =  NA   | "targetChannels"          : DescValueType.LISTTYPE
Key 17 =  NA   | "visibleChannels"         : DescValueType.LISTTYPE
Key 18 =  NA   | "channelRestrictions"     : DescValueType.LISTTYPE
Key 19 =  NA   | "fillOpacity"             : DescValueType.INTEGERTYPE
Key 20 =  NA   | "hasUserMask"             : DescValueType.BOOLEANTYPE
Key 21 =  NA   | "hasVectorMask"           : DescValueType.BOOLEANTYPE
Key 22 =  NA   | "hasFilterMask"           : DescValueType.BOOLEANTYPE
Key 23 =  NA   | "userMaskDensity"         : DescValueType.INTEGERTYPE
Key 24 =  NA   | "userMaskFeather"         : DescValueType.DOUBLETYPE
Key 25 =  NA   | "vectorMaskDensity"       : DescValueType.INTEGERTYPE
Key 26 =  NA   | "vectorMaskFeather"       : DescValueType.DOUBLETYPE
Key 27 =  NA   | "bounds"                  : DescValueType.OBJECTTYPE
Key 28 =  NA   | "layer3D"                 : DescValueType.OBJECTTYPE
A DescValueType.OBJECTTYPE is another descriptor. From looking at the output the key we need is stringIDToTypeID("layer3D"). So knowing that we change the first line after the top function to this and rerun the script.
Code: Select allvar desc = getDescriptor(charIDToTypeID("Lyr ") , stringIDToTypeID("layer3D") );
and the console outputs
Code: Select all[ActionDescriptor]
Key 01 =  NA   | "frameReaderType"         : DescValueType.INTEGERTYPE
Key 02 =  NA   | "descVersion"             : DescValueType.INTEGERTYPE
Key 03 =  NA   | "documentSize"            : DescValueType.OBJECTTYPE
Key 04 = "Ofst" | "offset"                  : DescValueType.OBJECTTYPE
Key 05 = "Grad" | "gradient"                : DescValueType.OBJECTTYPE
Key 06 =  NA   | "gradientLayer"           : DescValueType.OBJECTTYPE
Key 07 =  NA   | "key3DScene"              : DescValueType.OBJECTTYPE
Key 08 =  NA   | "keyBBoxCenterX"          : DescValueType.DOUBLETYPE
Key 09 =  NA   | "keyBBoxCenterY"          : DescValueType.DOUBLETYPE
Key 10 =  NA   | "keyBBoxCenterZ"          : DescValueType.DOUBLETYPE
Key 11 =  NA   | "keyBBoxMinX"             : DescValueType.DOUBLETYPE
Key 12 =  NA   | "keyBBoxMinY"             : DescValueType.DOUBLETYPE
Key 13 =  NA   | "keyBBoxMinZ"             : DescValueType.DOUBLETYPE
Key 14 =  NA   | "keyBBoxMaxX"             : DescValueType.DOUBLETYPE
Key 15 =  NA   | "keyBBoxMaxY"             : DescValueType.DOUBLETYPE
Key 16 =  NA   | "keyBBoxMaxZ"             : DescValueType.DOUBLETYPE
Key 17 =  NA   | "key3DViewIndexString"    : DescValueType.STRINGTYPE
Key 18 =  NA   | "key3DViewIndex"          : DescValueType.INTEGERTYPE
Key 19 =  NA   | "key3DObjectPositionIndexString" : DescValueType.STRINGTYPE
Key 20 =  NA   | "key3DFileName"           : DescValueType.STRINGTYPE
Key 21 =  NA   | "key3DDuration"           : DescValueType.DOUBLETYPE
Key 22 =  NA   | "key3DStateList"          : DescValueType.LISTTYPE
Key 23 =  NA   | "key3DTexturesExternal"   : DescValueType.BOOLEANTYPE
Key 24 =  NA   | "key3DTexturesVisible"    : DescValueType.BOOLEANTYPE
Key 25 =  NA   | "key3DTextureList"        : DescValueType.LISTTYPE
Key 26 =  NA   | "key3DState"              : DescValueType.OBJECTTYPE
Key 27 = "repo" |   NA    : DescValueType.BOOLEANTYPE
Key 28 =  NA   | "key3DCurrentEngine"      : DescValueType.STRINGTYPE
Key 29 =  NA   | "presetFileName"          : DescValueType.STRINGTYPE
Key 30 =  NA   | "presetLightName"         : DescValueType.STRINGTYPE
I don't see any of the keys we need so next we will look for a nested descriptor. Here I am going to guess that the key we need next is stringIDToTypeID("key3DState"). I would think that they will either be in that descriptor or in the list( a list can contain multiple descriptors ) "key3DStateList" and lists are harder to explore so I try "key3DState" first. To check that key I add this line below the first like so and rerun the script.
Code: Select allvar desc = getDescriptor(charIDToTypeID("Lyr ") , stringIDToTypeID("layer3D") );
desc = desc.getObjectValue( stringIDToTypeID("key3DState") );// get the nested descriptor
$.writeln( desc );
And the output looks something like this
Code: Select all[ActionDescriptor]
Key 01 =  NA   | "key3DStateName"          : DescValueType.STRINGTYPE
Key 02 =  NA   | "key3DCurrentCameraPosition" : DescValueType.OBJECTTYPE
Key 03 =  NA   | "key3DCurrentFOV"         : DescValueType.DOUBLETYPE
Key 04 =  NA   | "key3DCurrentFStop"       : DescValueType.DOUBLETYPE
Key 05 =  NA   | "key3DCurrentFDist"       : DescValueType.DOUBLETYPE
Key 06 =  NA   | "key3DCurrentFocalPointX" : DescValueType.DOUBLETYPE
Key 07 =  NA   | "key3DCurrentFocalPointY" : DescValueType.DOUBLETYPE
Key 08 =  NA   | "key3DCurrentPosition"    : DescValueType.OBJECTTYPE
Key 09 =  NA   | "key3DCurrentObjectXScale" : DescValueType.DOUBLETYPE
Key 10 =  NA   | "key3DCurrentObjectYScale" : DescValueType.DOUBLETYPE
Key 11 =  NA   | "key3DCurrentObjectZScale" : DescValueType.DOUBLETYPE
Key 12 =  NA   | "key3DOrthographic"       : DescValueType.INTEGERTYPE
Key 13 =  NA   | "key3DOrthographicScale"  : DescValueType.DOUBLETYPE
Key 14 =  NA   | "key3DTime"               : DescValueType.DOUBLETYPE
Key 15 =  NA   | "key3DCrossSection"       : DescValueType.OBJECTTYPE
Key 16 =  NA   | "key3DRenderSettings"     : DescValueType.OBJECTTYPE
Key 17 = "GamR" |   NA    : DescValueType.DOUBLETYPE
Key 18 = "GamG" |   NA    : DescValueType.DOUBLETYPE
Key 19 = "GamB" |   NA    : DescValueType.DOUBLETYPE
Key 20 =  NA   | "key3DStateType"          : DescValueType.INTEGERTYPE
Key 21 =  NA   | "printerResolution"       : DescValueType.DOUBLETYPE
Key 22 =  NA   | "toggleGroundPlaneShadowCatcher" : DescValueType.BOOLEANTYPE
Key 23 = "Bckg" | "background"              : DescValueType.BOOLEANTYPE
Key 24 =  NA   | "paint3DReflection"       : DescValueType.BOOLEANTYPE
We found the scale keys and guessing from looking at the scriptlistener code it's a good bet the other keys are in "key3DCurrentPosition". To make sure modify this line
Code: Select alldesc = desc.getObjectValue( stringIDToTypeID("key3DState") ).getObjectValue( stringIDToTypeID("key3DCurrentPosition") );
And we found the other needed keys.
Code: Select all[ActionDescriptor]
Key 01 =  NA   | "key3DXPos"               : DescValueType.DOUBLETYPE
Key 02 =  NA   | "key3DYPos"               : DescValueType.DOUBLETYPE
Key 03 =  NA   | "key3DZPos"               : DescValueType.DOUBLETYPE
Key 04 =  NA   | "key3DXAngle"             : DescValueType.DOUBLETYPE
Key 05 =  NA   | "key3DYAngle"             : DescValueType.DOUBLETYPE
Key 06 =  NA   | "key3DZAngle"             : DescValueType.DOUBLETYPE
So now we clean up the script. First remove all the code starting with line $.writeln( desc );. That part was only needed to explore the descriptors and is no longer needed. We will add a function to make a dupe of the descriptors we want to edit. Then add back the parts of the original scriptlistener code we need to create a new function to set the Z angle only.
Code: Select allfunction set3DZAngle( angle ){
   function getDescriptor( psClass, psKey ){
      var ref;
      ref = new ActionReference();
      if( psKey != undefined ) ref.putProperty( charIDToTypeID( "Prpr" ), psKey );
      ref.putEnumerated( psClass , charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
      return psKey != undefined ? executeActionGet(ref).getObjectValue( psKey ):executeActionGet(ref);
   };
   function duplicateDescriptor( descriptor ) {
      var newDescriptor;
      newDescriptor = new ActionDescriptor;
      newDescriptor.fromStream( descriptor.toStream() );
      return newDescriptor;
   };
   var desc = getDescriptor(charIDToTypeID("Lyr ") , stringIDToTypeID("layer3D") );
   // make copies of the descriptor we need to edit.
   stateDesc = duplicateDescriptor( desc.getObjectValue( stringIDToTypeID("key3DState") ) );
   positionDesc = duplicateDescriptor( stateDesc.getObjectValue( stringIDToTypeID("key3DCurrentPosition") ) );

   positionDesc.putDouble( stringIDToTypeID( "key3DZAngle" ), angle );
   stateDesc.putObject( stringIDToTypeID( "key3DCurrentPosition" ), stringIDToTypeID( "key3DCurrentPosition" ), positionDesc );
   executeAction( stringIDToTypeID( "set3DObjectPosition" ), stateDesc, DialogModes.NO );
};
Note we could have gotten the need values from each of the descriptor and created new descriptor like the original scriptlistener code did. But I think duping is better and maybe safer.

You will have to let me know if this works like you expect it would. It runs without error for me and does change the look of the layer. I am just not sure that it is only changing the Z angle.

Mike

Limey

Rotate a 3D object on Z Axis with no re-scaling

Postby Limey » Fri Dec 14, 2012 3:42 am

Thanks Mike! I will try it when I get to work tomorrow. I only have CS4 on my home computer.
I'm glad you posted this here. I hope your tutorial will help others too. I am going to study it and break it down till I understand it. Always so much to learn.

I'll let you know how it goes,

Paul (Limey)

Mike Hale

Rotate a 3D object on Z Axis with no re-scaling

Postby Mike Hale » Fri Dec 14, 2012 1:30 pm

If there is any part that you don't understand fully let me know and I will try to explain it in more detail.

Limey

Rotate a 3D object on Z Axis with no re-scaling

Postby Limey » Fri Dec 14, 2012 8:08 pm

Hi Mike,
I was able to follow your lead and found the keys as you described.
Code: Select all[ActionDescriptor]
Key 01 = "Nm  " | "name"                    : DescValueType.STRINGTYPE
Key 02 = "Clr " | "color"                   : DescValueType.ENUMERATEDTYPE
Key 03 = "Vsbl" | "visible"                 : DescValueType.BOOLEANTYPE
Key 04 = "Md  " | "mode"                    : DescValueType.ENUMERATEDTYPE
Key 05 = "Opct" | "opacity"                 : DescValueType.INTEGERTYPE
Key 06 = "LyrI" | "layerID"                 : DescValueType.INTEGERTYPE
Key 07 = "ItmI" | "itemIndex"               : DescValueType.INTEGERTYPE
Key 08 = "Cnt " | "count"                   : DescValueType.INTEGERTYPE
Key 09 = "PrsT" | "preserveTransparency"    : DescValueType.BOOLEANTYPE
Key 10 = "lfxv" | "layerFXVisible"          : DescValueType.BOOLEANTYPE
Key 11 = "gblA" | "globalAngle"             : DescValueType.INTEGERTYPE
Key 12 = "Bckg" | "background"              : DescValueType.BOOLEANTYPE
Key 13 =  NA   | "layerSection"            : DescValueType.ENUMERATEDTYPE
Key 14 =  NA   | "layerLocking"            : DescValueType.OBJECTTYPE
Key 15 = "Grup" | "group"                   : DescValueType.BOOLEANTYPE
Key 16 =  NA   | "targetChannels"          : DescValueType.LISTTYPE
Key 17 =  NA   | "visibleChannels"         : DescValueType.LISTTYPE
Key 18 =  NA   | "channelRestrictions"     : DescValueType.LISTTYPE
Key 19 =  NA   | "fillOpacity"             : DescValueType.INTEGERTYPE
Key 20 =  NA   | "hasUserMask"             : DescValueType.BOOLEANTYPE
Key 21 =  NA   | "hasVectorMask"           : DescValueType.BOOLEANTYPE
Key 22 =  NA   | "hasFilterMask"           : DescValueType.BOOLEANTYPE
Key 23 =  NA   | "userMaskDensity"         : DescValueType.INTEGERTYPE
Key 24 =  NA   | "userMaskFeather"         : DescValueType.DOUBLETYPE
Key 25 =  NA   | "vectorMaskDensity"       : DescValueType.INTEGERTYPE
Key 26 =  NA   | "vectorMaskFeather"       : DescValueType.DOUBLETYPE
Key 27 =  NA   | "bounds"                  : DescValueType.OBJECTTYPE
Key 28 =  NA   | "layer3D"                 : DescValueType.OBJECTTYPE
[ActionDescriptor]
Key 01 =  NA   | "frameReaderType"         : DescValueType.INTEGERTYPE
Key 02 =  NA   | "descVersion"             : DescValueType.INTEGERTYPE
Key 03 =  NA   | "documentSize"            : DescValueType.OBJECTTYPE
Key 04 = "Ofst" | "offset"                  : DescValueType.OBJECTTYPE
Key 05 = "Grad" | "gradient"                : DescValueType.OBJECTTYPE
Key 06 =  NA   | "gradientLayer"           : DescValueType.OBJECTTYPE
Key 07 =  NA   | "key3DScene"              : DescValueType.OBJECTTYPE
Key 08 =  NA   | "keyBBoxCenterX"          : DescValueType.DOUBLETYPE
Key 09 =  NA   | "keyBBoxCenterY"          : DescValueType.DOUBLETYPE
Key 10 =  NA   | "keyBBoxCenterZ"          : DescValueType.DOUBLETYPE
Key 11 =  NA   | "keyBBoxMinX"             : DescValueType.DOUBLETYPE
Key 12 =  NA   | "keyBBoxMinY"             : DescValueType.DOUBLETYPE
Key 13 =  NA   | "keyBBoxMinZ"             : DescValueType.DOUBLETYPE
Key 14 =  NA   | "keyBBoxMaxX"             : DescValueType.DOUBLETYPE
Key 15 =  NA   | "keyBBoxMaxY"             : DescValueType.DOUBLETYPE
Key 16 =  NA   | "keyBBoxMaxZ"             : DescValueType.DOUBLETYPE
Key 17 =  NA   | "key3DViewIndexString"    : DescValueType.STRINGTYPE
Key 18 =  NA   | "key3DViewIndex"          : DescValueType.INTEGERTYPE
Key 19 =  NA   | "key3DObjectPositionIndexString" : DescValueType.STRINGTYPE
Key 20 =  NA   | "key3DFileName"           : DescValueType.STRINGTYPE
Key 21 =  NA   | "key3DDuration"           : DescValueType.DOUBLETYPE
Key 22 =  NA   | "key3DStateList"          : DescValueType.LISTTYPE
Key 23 =  NA   | "key3DTexturesExternal"   : DescValueType.BOOLEANTYPE
Key 24 =  NA   | "key3DTexturesVisible"    : DescValueType.BOOLEANTYPE
Key 25 =  NA   | "key3DTextureList"        : DescValueType.LISTTYPE
Key 26 =  NA   | "key3DState"              : DescValueType.OBJECTTYPE
Key 27 = "repo" |   NA    : DescValueType.BOOLEANTYPE
Key 28 =  NA   | "key3DCurrentEngine"      : DescValueType.STRINGTYPE
Key 29 =  NA   | "presetFileName"          : DescValueType.STRINGTYPE
Key 30 =  NA   | "presetLightName"         : DescValueType.STRINGTYPE
[ActionDescriptor]
Key 01 =  NA   | "key3DStateName"          : DescValueType.STRINGTYPE
Key 02 =  NA   | "key3DCurrentCameraPosition" : DescValueType.OBJECTTYPE
Key 03 =  NA   | "key3DCurrentFOV"         : DescValueType.DOUBLETYPE
Key 04 =  NA   | "key3DCurrentFStop"       : DescValueType.DOUBLETYPE
Key 05 =  NA   | "key3DCurrentFDist"       : DescValueType.DOUBLETYPE
Key 06 =  NA   | "key3DCurrentFocalPointX" : DescValueType.DOUBLETYPE
Key 07 =  NA   | "key3DCurrentFocalPointY" : DescValueType.DOUBLETYPE
Key 08 =  NA   | "key3DCurrentPosition"    : DescValueType.OBJECTTYPE
Key 09 =  NA   | "key3DCurrentObjectXScale" : DescValueType.DOUBLETYPE
Key 10 =  NA   | "key3DCurrentObjectYScale" : DescValueType.DOUBLETYPE
Key 11 =  NA   | "key3DCurrentObjectZScale" : DescValueType.DOUBLETYPE
Key 12 =  NA   | "key3DOrthographic"       : DescValueType.INTEGERTYPE
Key 13 =  NA   | "key3DOrthographicScale"  : DescValueType.DOUBLETYPE
Key 14 =  NA   | "key3DTime"               : DescValueType.DOUBLETYPE
Key 15 =  NA   | "key3DCrossSection"       : DescValueType.OBJECTTYPE
Key 16 =  NA   | "key3DRenderSettings"     : DescValueType.OBJECTTYPE
Key 17 = "GamR" |   NA    : DescValueType.DOUBLETYPE
Key 18 = "GamG" |   NA    : DescValueType.DOUBLETYPE
Key 19 = "GamB" |   NA    : DescValueType.DOUBLETYPE
Key 20 =  NA   | "key3DStateType"          : DescValueType.INTEGERTYPE
Key 21 =  NA   | "printerResolution"       : DescValueType.DOUBLETYPE
Key 22 =  NA   | "toggleGroundPlaneShadowCatcher" : DescValueType.BOOLEANTYPE
Key 23 = "Bckg" | "background"              : DescValueType.BOOLEANTYPE
Key 24 =  NA   | "paint3DReflection"       : DescValueType.BOOLEANTYPE
[ActionDescriptor]
Key 01 =  NA   | "key3DXPos"               : DescValueType.DOUBLETYPE
Key 02 =  NA   | "key3DYPos"               : DescValueType.DOUBLETYPE
Key 03 =  NA   | "key3DZPos"               : DescValueType.DOUBLETYPE
Key 04 =  NA   | "key3DXAngle"             : DescValueType.DOUBLETYPE
Key 05 =  NA   | "key3DYAngle"             : DescValueType.DOUBLETYPE
Key 06 =  NA   | "key3DZAngle"             : DescValueType.DOUBLETYPE

So that was a measure of success and after studying the code you used I think I an starting to understand the structure a little more. I tried running the code you gave at the end (but nothing happened for me. I don't see any value to rotate in the code so can I assume that I still need to add the part from Script listener?
This was from a script listener after I rotated the cylinder to the 270 degree angle. Do I need to use the 2 lines related to "key3DZAngle"?

Code: Select allvar idsetthreeDObjectPosition = stringIDToTypeID( "set3DObjectPosition" );
    var desc458 = new ActionDescriptor();
    var idkeythreeDCurrentPosition = stringIDToTypeID( "key3DCurrentPosition" );
        var desc459 = new ActionDescriptor();
        var idkeythreeDXPos = stringIDToTypeID( "key3DXPos" );
        desc459.putDouble( idkeythreeDXPos, 0.551146 );
        var idkeythreeDYPos = stringIDToTypeID( "key3DYPos" );
        desc459.putDouble( idkeythreeDYPos, -0.618277 );
        var idkeythreeDZPos = stringIDToTypeID( "key3DZPos" );
        desc459.putDouble( idkeythreeDZPos, 0.635015 );
        var idkeythreeDXAngle = stringIDToTypeID( "key3DXAngle" );
        desc459.putDouble( idkeythreeDXAngle, 0.000005 );
        var idkeythreeDYAngle = stringIDToTypeID( "key3DYAngle" );
        desc459.putDouble( idkeythreeDYAngle, 0.000000 );
        var idkeythreeDZAngle = stringIDToTypeID( "key3DZAngle" );
        desc459.putDouble( idkeythreeDZAngle, 270.000000 );
    var idkeythreeDCurrentPosition = stringIDToTypeID( "key3DCurrentPosition" );
    desc458.putObject( idkeythreeDCurrentPosition, idkeythreeDCurrentPosition, desc459 );
    var idkeythreeDCurrentObjectXScale = stringIDToTypeID( "key3DCurrentObjectXScale" );
    desc458.putDouble( idkeythreeDCurrentObjectXScale, 1.754662 );
    var idkeythreeDCurrentObjectYScale = stringIDToTypeID( "key3DCurrentObjectYScale" );
    desc458.putDouble( idkeythreeDCurrentObjectYScale, 1.737562 );
    var idkeythreeDCurrentObjectZScale = stringIDToTypeID( "key3DCurrentObjectZScale" );
    desc458.putDouble( idkeythreeDCurrentObjectZScale, 1.049131 );
executeAction( idsetthreeDObjectPosition, desc458, DialogModes.NO );

 

Thanks Mike!

Paul (Limey)

Mike Hale

Rotate a 3D object on Z Axis with no re-scaling

Postby Mike Hale » Fri Dec 14, 2012 9:00 pm

Sorry if I wasn't clear. The last bit of code I posted was just a function to change the angle. By it's self it would not do anything. To use the function you need to call it. Something like this
Code: Select allset3DZAngle( 270 );

As I said it works here( or at least it changes the look of the image ). But on my 32bit Windows XP system without a GPU video card it is slow because of the need to do a software render.

Mike Hale

Rotate a 3D object on Z Axis with no re-scaling

Postby Mike Hale » Fri Dec 14, 2012 9:25 pm

In hope that more info may be helpful.
Code: Select all// the top lines of the new function should be here

// make a new descriptor using the existing values from the layer. These keys are the same as desc10 in the first scriptlistener code.
stateDesc = duplicateDescriptor( desc.getObjectValue( stringIDToTypeID("key3DState") ) );

// make a new descriptor using the existing values from the layer. These keys are the same as desc9 in the first scriptlistener code.
positionDesc = duplicateDescriptor( stateDesc.getObjectValue( stringIDToTypeID("key3DCurrentPosition") ) );

// we only want to change the Z angle so we will overwrite the existing value with a new one.
positionDesc.putDouble( stringIDToTypeID( "key3DZAngle" ), angle );// function argument

// now we put that edited descriptor into the "key3DCurrentPosition" descriptor - the way desc10 was put into desc9
stateDesc.putObject( stringIDToTypeID( "key3DCurrentPosition" ), stringIDToTypeID( "key3DCurrentPosition" ), positionDesc );

// then we set that descriptor to the layer using "set3DObjectPosition" - still following the original scriptlistener code structure.
executeAction( stringIDToTypeID( "set3DObjectPosition" ), stateDesc, DialogModes.NO );

Limey

Rotate a 3D object on Z Axis with no re-scaling

Postby Limey » Sat Dec 15, 2012 1:10 am

Mike, as always you are freekin' awesome! Works like a charm and renders automatically. It rotates the cylinder perfectly without altering anything else.

I'm diving in and breaking the process down. I am convicted to learn this one way or another. I have to learn the "Lingo" first. I spoke to our web programmers here at work that program in all kinds of languages as well as Java Script but they said that it was hard to understand the Photoshop JS.
Do you think if I was to invest in a Java Script course at a junior college or online it would help me understand creating the functions and understand enough of the terminology, like what a descriptor, key, class and object are and do. I think understanding the principles and syntax are going to be key my understanding how to script PS.

Again, thanks for the help and inspiration,

Limey


Return to “Automation & Image Workflow”

Who is online

Users browsing this forum: No registered users and 11 guests