Polyextrudefacet Being Inconsistent

I am facing a problem with the "polyExtrudeFacet" command. I have a polygonal mesh "pCube1". Now I duplicate the geometry "pCube1" as "copy" parented under "world" to create another identical geometry "pCube2" without any transformations. I extrude face on the original geometry "pCube1" and using the local manipulator tool that appears, I translate, rotate and scale the newly extruded face. This gives me the following series of commands.

polyExtrudeFacet -ch 1 -kft 1 -pvx 0.5 -pvy 0 -pvz -0.25 -tx 0 -ty 0 -tz 0 -rx 0 -ry 0 -rz 0 -sx 1 -sy 1 -sz 1 -ran 0 -divisions 1 -twist 0 -taper 1 -off 0 -ltz 0 -ws 0 -ltx 0 -lty 0 -lrx 0 -lry 0 -lrz 0 -lsx 1 -lsy 1 -lsz 1 -ldx 1 -ldy 0 -ldz 0 -w 0 -gx 0 -gy -1 -gz 0 -att 0 -mx 0 -my 0 -mz 0 -sma 30 pCube1.f[4];
setAttr "polyExtrudeFace1.localTranslate" -type double3 0 0 0.86538 ;
setAttr "polyExtrudeFace1.localScale" -type double3 1.848825 1 1 ;
setAttr "polyExtrudeFace1.localRotate" -type double3 -0.649465 0 0 ;
setAttr "polyExtrudeFace1.localRotate" -type double3 -0.729703 0.434298 -0.359939 ;
setAttr "polyExtrudeFace1.localRotate" -type double3 -0.0470129 0.434298 -0.359939 ;
setAttr "polyExtrudeFace1.localScale" -type double3 1.848825 1.951747 1 ;

Now I want is to automate the extrusion process on the "pCube2" just by using MEL script to create a structure similar to the original one "pCube1". So I execute the below given script(apart from red text rest all is same as the above command sequence)

string $m[];
$m = polyExtrudeFacet -ch 1 -kft 1 -pvx 0.5 -pvy 0 -pvz -0.25 -tx 0 -ty 0 -tz 0 -rx 0 -ry 0 -rz 0 -sx 1 -sy 1 -sz 1 -ran 0 -divisions 1 -twist 0 -taper 1 -off 0 -ltz 0 -ws 0 -ltx 0 -lty 0 -lrx 0 -lry 0 -lrz 0 -lsx 1 -lsy 1 -lsz 1 -ldx 1 -ldy 0 -ldz 0 -w 0 -gx 0 -gy -1 -gz 0 -att 0 -mx 0 -my 0 -mz 0 -sma 30 pCube2.f[4];
setAttr ($m[0] + ".localTranslate") -type double3 0 0 0.86538 ;
setAttr ($m[0] + ".localScale") -type double3 1.848825 1 1 ;
setAttr ($m[0] + ".localRotate") -type double3 -0.649465 0 0 ;
setAttr ($m[0] + ".localRotate") -type double3 -0.729703 0.434298 -0.359939 ;
setAttr ($m[0] + ".localRotate") -type double3 -0.0470129 0.434298 -0.359939 ;
setAttr ($m[0] + ".localScale") -type double3 1.848825 1.951747 1 ;

But the final structure of pCube2 does not match that of pCube1. Also I found out if there is no scaling and rotation involved, it works. Probably it has got some thing to do with the pivot of rotation and scaling. Is there a way to get this done. Basically all I want to do is save the transformations on one geometry as sequence of MEL instructions and later on apply them on a similar geometry to create a desired structure. The one at the center of the grid is "pCube2".
http://www.imagehosting.com

Yes scale and rotate are sensitve to locality, in this case its important that you move the TRNASFORM and not the components, also you should have SAME uv map as the u and v directions APPLY on UV corinate space.

However, this is to say it works but theres a easier way to do this, than transcribing the mel, you can just

  • At easiest instance the shaep under a new trasform
  • Split history tree, use the create of the node 1 as bassis for node 2
  • duplicate the node in the chain and connect it into the history of node 2 (this is exactly teha sema as above EXCEPT it can duplicate everything ever dine with same piece of code, and you dont need to record anything)
  • 3 even works on repective selection on same node.

    Note however that you can actually collapse your code into 1 line! Because the creation of extrude has flags for al those attributes as for example the fag -lsx is local scale x. Also your settars are a bit extra since you ste the same thing 2 times and thy dont accumulate

    Hi

    Something else you could do if you want to use a "repeat" operation is to do the extrude on cube 2 using cube 1 extrusion settings then move cube 2 to postion i.e. do all extrudes etc at position 0 0 0 (or wherever) then move "finalised" object to desired position. This will only work if you are creating or setting the 2 cubes at same position intially.

    QUOTE(Davvey @ 04/08/07, 02:24 PM) [snapback]263698[/snapback]
    Hi

    Something else you could do if you want to use a "repeat" operation is to do the extrude on cube 2 using cube 1 extrusion settings then move cube 2 to postion i.e. do all extrudes etc at position 0 0 0 (or wherever) then move "finalised" object to desired position. This will only work if you are creating or setting the 2 cubes at same position intially.

    Both were at the same place i.e at position 0 0 0 at the time of applying the transformations. I separated them after wards.

    yes but did they have same UV coordinates, because local movements x and y axes are defined by how the uvs are laid out. So if the uvs are slanted differently then that means different result

    QUOTE(Joojaa @ 04/08/07, 01:13 PM) [snapback]263692[/snapback]
    Yes scale and rotate are sensitve to locality, in this case its important that you move the TRNASFORM and not the components, also you should have SAME uv map as the u and v directions APPLY on UV corinate space.
    However, this is to say it works but theres a easier way to do this, than transcribing the mel, you can just

  • At easiest instance the shaep under a new trasform
  • Split history tree, use the create of the node 1 as bassis for node 2
  • duplicate the node in the chain and connect it into the history of node 2 (this is exactly teha sema as above EXCEPT it can duplicate everything ever dine with same piece of code, and you dont need to record anything)
  • 3 even works on repective selection on same node.
    Note however that you can actually collapse your code into 1 line! Because the creation of extrude has flags for al those attributes as for example the fag -lsx is local scale x. Also your settars are a bit extra since you ste the same thing 2 times and thy dont accumulate

    I am not sure if I have understood the solution suggested by you completely. But one thing I feel that it might not help. Ok I'll explain what exactly I want to do. Lets say we start with a simple geometry. we modify it tweak it to create a detailed model of something. I record all these modifications as a series of commands in a file and save it for later use. Now if I start with the same basic shape and apply these commands in the proper sequence, it should generate the same detailed structure out of that basic shape. Also having the sequence of commands helps me getting to a desired intermediate stage of construction.

    I dont know. How do I make sure that both of them had the same UV coordinates. The second object was created by duplicate command with "copy" and "group under world" as settings. I am not aware if that changes the UV coordinates

    I just discovered that Maya script editor does not echo any MEL command for splitPolyVertex execution unless I change its settings to "echo all" which then outputs all sort of unwanted crap. Is there a way to detect the execution of this or for that matter any other MEL command.

    well you might not think so but i do . History is everything, As long as no-one deletes history of course. But thing is history is the same record you just made, if you save out it as a ma file you will notice thats just exactly what maya does. (trick you can get the history in mel code form the ma file!)

    its just that recording all changes is harder than reading the history. Your in essence trying to mimic history but the awkward way.

    let us suppose the involved shape:

    CODE
    // lets make a new file
    file -f -new;
    constructionHistory -toggle true;

    //leyts create some history to work on
    polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1;
    polyExtrudeFacet -constructionHistory 1 -keepFacesTogether 0
                     -pvx 0 -pvy 0.5 -ltz 10 -pvz 0 -divisions 1 -twist 0 -taper 1 -off 0
                     -smoothingAngle 30 pCube1.f[0:5];
    scale -r -p 0 0 0 6 6 6  pCube1.vtx[0:7];
    polySmooth  -mth 0 -dv 2 -c 1 -kb 1 -ksb 1 -khe 0
                -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 pCube1;
    polyExtrudeFacet -constructionHistory 1 -keepFacesTogether 1 -pvx 0 -pvy 0
                     -ltz 1 -pvz 0 -divisions 1 -twist 0 -taper 1 -off 0.3
                     -smoothingAngle 30
    pCube1.f[140] pCube1.f[143] pCube1.f[146] pCube1.f[149] pCube1.f[152]
    pCube1.f[155] pCube1.f[158] pCube1.f[161] pCube1.f[164] pCube1.f[167]
    pCube1.f[170] pCube1.f[173] pCube1.f[176] pCube1.f[179] pCube1.f[182]
    pCube1.f[185] pCube1.f[188] pCube1.f[191] pCube1.f[194] pCube1.f[197]
    pCube1.f[200] pCube1.f[203] pCube1.f[206] pCube1.f[209] pCube1.f[266]
    pCube1.f[275] pCube1.f[284] pCube1.f[293] pCube1.f[302] pCube1.f[311]
    pCube1.f[320] pCube1.f[329] pCube1.f[338] pCube1.f[347] pCube1.f[356]
    pCube1.f[365] pCube1.f[374] pCube1.f[383] pCube1.f[392] pCube1.f[401]
    pCube1.f[410] pCube1.f[419] pCube1.f[428] pCube1.f[437] pCube1.f[446]
    pCube1.f[455] pCube1.f[464] pCube1.f[473];

    now let us suppose for a minute i didnt see the artist doing it and i never saw the code above, can i recreate the steps? Well it so happens i can its all there as part of history (and in case of point movenments in tweaks of the shape itself, but thats overcourse, but they can be recorderd too)

    Now i can playback the entire history without knowing the above (watchh thy viewport):

    CODE
    //play back history stepnby step on ANY
    //maya object with history
    {//protect variable pollution
    string $historyChain=listHistory pCube1;
    for ($i=1;$i<size($historyChain)-1;$i++){
      setAttr ($historyChain[$i]+".nodeState") 1;
      refresh;
      pause -sec 1;
    }
    }

    NOTE: if you wish you could save the scene now, exit maya and still get it to work on next steps or any of them

    and resume it back.

    CODE
    {//protect variable pollution
    string $historyChain[]=listHistory pCube1;
    for ($i=size($historyChain)-1;$i>0;$i--){
      setAttr ($historyChain[$i]+".nodeState") 0;
      refresh;
      pause -sec 1;
    }
    }

    now lets assume i want to go to the stage before the last extrude and do some changes, id need to inject a tweak node or a shape node to contain the changes.

    So assuming the same scene (if you investigated steps thisfar start over):

    CODE
    //assuming scene created earlier
    {//protect variable pollution
      setAttr ("polyExtrudeFace2.nodeState") 1;
      $mesh=createNode mesh;
      connectAttr -f polySmoothFace1.output ($mesh+".inMesh");
      $a=listRelatives -p $mesh;
      //lets hide the changer its not essential
      setAttr ($a[0]+".intermediateObject") 1;
      move -r -os -wd 0 3 0 ($a[0]+".vtx[165]");
      connectAttr -f ($mesh+".outMesh") polyExtrudeFace2.inputPolymesh;
      refresh;
      pause -sec 1;
      setAttr ("polyExtrudeFace2.nodeState") 0;
    }

    Now above code works much more versatilely on anything.

    Ok, now the power trick the intermediate shape is actually part of the history but you can tweak it interactively. Let us assume you didn't change anything in the run for simplicity (as i have limited time):
    CODE
    setAttr ("polySurface1.intermediateObject") 0;
    move -r -os -wd 20 0 0 polySurface1;

    now see this mesh has no surface as its just a history ghost of the shape however move the points in this shape and see that the future updates. And that was point number 2.

    This offcourse you should know since you use it in smooths and animation all the time.

    NOTE 2: theres much more to history than this, it can even branch in any manner you like use the hyper graph to investigate it

    NOTE 3: yes you can change the affected faces of a history node later if you wish and duplicate longer parts of chain to different parts of a object.

    PS all was tested in maya 8.5 but should work on everything else.

    PPS
    hope you undertand my drift and maya better now.

    Thank you very much for such a nice explanation that introduced me to a whole new aspect of Maya. Though it took me some time to digest the matter but now that I have understood it, I believe my understanding of Maya's working has gotten better. I do realize how dumb and inefficient my initial approach was . now that I've got my toes wet I'll proceed to plunge into greater depths . One last last question. In code piece 4, Line Number 8 "setAttr ($a[0]+".intermediateObject") 1;" why did you use the attribute "intermediateObject" instead of "visibility" to hide the object. I am skeptical because the documentation about "intermediateObject" reads "This attribute is automatically set so changing this value may cause unpredictable results." This sounds like a stupid question but I am curious and expecting an answer that only an experienced user can give. Is this attribute "intermediateObject" an important one or is just like the numerous others that offer greater customization but are better left untouched?

    Well they have 2 different meanings.

    visisbility is hidden, its stille there in the outliner its still visisble as a independent shape/object.

    Intermediary has different meaning, it means its just a part of my history of a abject and as such belongs to thet chain and needs no other hooks to be found. (ok so i make tthe trasform as intermediary that may be a bit overboard sincee strictly speaking transforms arent part of the history), its not hidden its just marked as a container for stuff. Things like booleans use this a lot. (since i work on RAW history its ok to set this also)