Wednesday, April 08, 2009

add something like [code][/code] in blogger

When you need to post multiple-line source codes(mel,C,python,whatever)..you need the exact format as in your code editor because it'll look much tidier. But if you paste the code here in the standard blogger post editor, it'd look as ugly as you can imagine. So I search the net the found this site (also a blogger site):

http://formatmysourcecode.blogspot.com/


Basically you just need to paste the codes there, and it'll return the "correct" formatting for you. And then you can paste them back to your post editor.

Here's an example of it:
{
polySelectConstraint -m 3 -t 0x8000 -w 1 ;
polySelectConstraint -dis;
$selection = `ls -sl -fl -l` ;

string $borderShell[];
int $borderSize[];
int $currSize=0;
for($currID= 0;$currID<size($selection);$currID++)
{

if($selection[$currID]=="")
continue;

$borderShell[$currSize] = $selection[$currID];


string $tmp[]=`polyListComponentConversion -fe -tv $selection[$currID]`;
string $verts[]=`ls -fl $tmp`;

int $found=0;
int $iter=0;
int $maxIter = 20000;
do
{
$found=0;

for($nID = 0;$nID<size($selection);$nID++)
{
if($selection[$nID]=="")
continue;

if($selection[$nID] == $selection[$currID])
continue;

$tmp=`polyListComponentConversion -fe -tv $selection[$nID]`;
string $nVerts[] = `ls -fl $tmp`;


for($i=0;$i<size($verts);$i++)
{

for($j=0;$j<size($nVerts);$j++)
{
if($verts[$i] == $nVerts[$j])
{
$borderShell[$currSize] = $borderShell[$currSize] + " " + $selection[$nID];
$selection[$currID]="";
$selection[$nID] = "";
$j =!$j;
$verts[$i] = $nVerts[$j];

$found=1;
break;

}
}

if($found)
break;
}
if($found)
break;
}
$iter+=1;
}while($found && $iter<$maxIter);

$currSize+=1;
}
print $borderShell;
}


The example codes above are mel codes. The usage is to organize border edges into each separate border shells.