Newbie Question!

Hey guys-

I am trying to get the hang of this mel stuff, and its been ogin pretty good, I just have one real basic question., and maybe you guys have the answer. I was trying to create a context sensitve script that did one thing if the selection was "this" and another if it was "that". More specifically, an extrude tool that would extrude edges if an edge was selected or faces if faces were selected. I am sure there is a script out there that already does this, but I'll never learn if I dont't try. Long story short... I started with this....
CODE
string $selType;

if (size(filterExpand -sm 32))

    $selType=2;

if (size(filterExpand -sm 34))

    $selType=1;

if ($selType=1)

polyExtrudeFacet;

else
{

if ($selType=2)

polyExtrudeEdge;
}

well... the results were not as expected. any ideas? It does fine with the faceExtrude, but just converts the edge selection to faces on the edge selection "if statement". It seems to be reading the $selType variable coreectly though. Thanks for your thoughts.

CODE
. . .
if( $selType == 1 )
. . .
if( $selType == 2 )
. . .

= asignment operator
== equality operator

Btw you should always brace your if/for blocks even if they consist of only one statement
bad:
CODE
if( $this == $that )
  $foo = $bar;

good:
CODE
if( $this == $that ){
  $foo = $bar;
}

Thanks Failure-

I tried this and got simulair results. I tried reversing the second if then statement, and got the reverse. It simply converts the selection over to the first command called, and does that extrusion. any other ideas? here is my new code.

CODE
$selected=ls -sl;

string $selType;
string $selTypeTrans;

if (size(filterExpand -sm 32)){

    $selType=2;
}
else

if (size(filterExpand -sm 34)){

    $selType=1;

}

print $selType;

print $selTypeTrans;

if ($selTypeTrans==2){

polyExtrudeEdge;
}
else

if ($selTypeTrans==1){

polyExtrudeFacet;

}

this new code always extrudes the selection as an edge selection!

if ($selTypeTrans==2){

polyExtrudeEdge;
}
else

if ($selTypeTrans==1){

polyExtrudeFacet;

}

You are testing $selTypeTrans in your code but you never assign anything to it - that cannot be correct. Why do you need that variable anyway? You also don't need list selection if you don't use it.

CODE
string $faces[] = filterExpand -sm 34;
string $edges[] = filterExpand -sm 32;

if( size( $faces ) ){
   polyExtrudeFacet -lt 0 0 1 $faces;
}

else if( size( $edges ) ){
   polyExtrudeEdge -lt 0 0 1 $edges;
}

If both, faces and edges are selected the above axample vill give priority to faces and ignore the edges.

Hey

I asked for this a while ago. Look what we were trying to do:
http://www.highend3d.com/boards/index.php?showtopic=176961

na.. By now my extrude scipt looks that way:
http://mel.goodsoul.de/scripts/smartExtrudeVEF.mel

Hey ewerbody-

I got it workin!, but now comes the finess. So far the two seperate extrusions work based on the "if then else" statements, but if history is enabled then the pivot for the extrude manip is placed at the location that it would appear the first time you run the script. I looked at the code maya builds when an extrude is done normally, it looks like you would have to get the local pivot info to place the new manip. (xform maybe??)
anyways I'll take a look at your script, maybe you already answered my question.

Here is the workin code:

CODE
global proc extrudeSP ()
{

$selected=ls -sl;
$consHist= constructionHistory -q -toggle;

string $selType;
string $selTypeTrans;

if (size(filterExpand -sm 32)){

    $selType=2;
}
else

if (size(filterExpand -sm 34)){

    $selType=1;

}

if ($selType==2){

polyExtrudeEdge -ch $consHist;
}
else

if ($selType==1){

polyExtrudeFacet -ch $

consHist;

}

}

obvioulsy this doesn't need to be turned into a Gloabal Proc, but I need the practice.

Thanks for all your thoughs, let me know if you come up with anything else.

Scott