It is currently Sat Oct 25, 2014 5:49 pm

Macro to generate derived layer hierarchically

Macro to generate derived layer hierarchically

Postby Tanner_AE_SB » Thu Jun 07, 2012 7:18 pm

//*************************************************************************
// Function Name : GenerateSpecialLayerInCell
// Parameters : pCell - Current cell operating on.
// nLevel - Current level in the hierarchy.
// Description : Generates the special layer in the cells that are at
// the correct level of the hierarchy. It marks each
// cell so that it only generates the layer once for
// each cell.
// Returns : Nothing.
//*************************************************************************
// Revision History
// 06/12/2007 - NJW - Created function.
//*************************************************************************
void GenerateSpecialLayerInCell(LCell pCell, int nLevel, int gnMaxLevel)
{
// Are we at the correct level of the hierarchy.
if(nLevel == gnMaxLevel)
{
// We are at the correct level.
// Now check if we have generate the layer in the cell already.
if(LEntity_PropertyExists((const LEntity)pCell, gszCellMarkPropertyName) != LStatusOK)
{
// We haven't done this cell so generate the layer and mark it.
LEntity_AssignProperty((LEntity)pCell, gszCellMarkPropertyName, L_int, &gnProcessed);
LCell_GenerateLayers_v11_10(pCell, &gpGenLayer, 1, LTRUE, LFALSE);
gnCounter++;
}
}
else
{
// Not at the right level of the hierarchy so keep going down.
LInstance pInstance = NULL;
for(pInstance = LInstance_GetList(pCell); Assigned(pInstance); pInstance = LInstance_GetNext(pInstance))
{
LCell pInstanceCell = LInstance_GetCell(pInstance);
GenerateSpecialLayerInCell(pInstanceCell, nLevel+1, gnMaxLevel);
}
}
}

//*************************************************************************
// Function Name : BoolOpSubLevel
// Parameters : None.
// Description : Main functions. Sets up global variables and calls
// the recursive function.
// Returns : Nothing.
//*************************************************************************
// Revision History
// 06/12/2007 - NJW - Created function.
//*************************************************************************
void BoolOpSubLevel(void)
{
LCell pCurrentCell = LCell_GetVisible();
LFile pTDBFile = LCell_GetFile(pCurrentCell);
gpGenLayer = LLayer_Find(pTDBFile, "Test_Derived");
int gnMaxLevel = 2;
static char TempGenLayer1[256] = "Test_Derived";
/***************************************************/

LDialogItem Dialog_Items[2];

//Parameter Names
strcpy(Dialog_Items[0].prompt, "Level Number(Level 0 is Current/Top level):");
strcpy(Dialog_Items[1].prompt, "Derived Layer to Generate:");

// Default Values which will appear in the input fields
sprintf(Dialog_Items[0].value, "%d", gnMaxLevel);
strcpy(Dialog_Items[1].value, TempGenLayer1);

//Calling the input parameter dialog
if(!LDialog_MultiLineInputBox("BoolOpSubLevel Parameters", Dialog_Items, 2))
{
return;
}

//Copying the input parameter values entered by user to variables
gnMaxLevel = atof(Dialog_Items[0].value);
strcpy(TempGenLayer1, Dialog_Items[1].value);
gpGenLayer = LLayer_Find(pTDBFile, TempGenLayer1);
//LDialog_MsgBox(LFormat("%d", gnMaxLevel));
/********************************************************/


// Get the current settings for Quiet and Update Modes.
int iQuietMode = LUpi_InQuietMode();
int iUpdateMode = LUpi_GetUpdateDisplayMode();
// Turn off Quiet Mode (Show warning dialog boxes) & Update Display Mode.
LUpi_SetQuietMode(1);
LUpi_SetUpdateDisplayMode(0);

gnCounter = 0;
GenerateSpecialLayerInCell(pCurrentCell, 0, gnMaxLevel );
LDialog_MsgBox(LFormat("Generated the special Layer in %ld cells.", gnCounter));

// Reset Quiet and Update mode back to what it
// was before the macro was run.
LUpi_SetQuietMode(iQuietMode);
LUpi_SetUpdateDisplayMode(iUpdateMode);

LDisplay_Refresh;
}
Tanner_AE_SB
 
Posts: 32
Joined: Thu Jun 07, 2012 2:37 pm

Return to UPI and TCL scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 35 on Thu Jan 09, 2014 2:15 am

Users browsing this forum: No registered users and 1 guest

Login Form