It is currently Wed Aug 27, 2014 10:56 am

Object Selection problems

Object Selection problems

Postby asc8y@virginia.edu » Tue Jun 26, 2012 9:10 am

Hi, I'm having with the LSelection_AddObject command within T-cell code. I always get the LStatus error = 7 "BadCell". Below is a sample code for generating the error. Any help would be appreciated.
-Allen


/* TODO: Put local functions here. */
void test2_main(void)
{
int iTmpUpiReturnCode = LUpi_GetReturnCode();
/* Begin DO NOT EDIT SECTION generated by L-Edit */
LCell cellCurrent = (LCell)LMacro_GetNewTCell();
double width = LCell_GetParameterAsDouble(cellCurrent, "width");
double height = LCell_GetParameterAsDouble(cellCurrent, "height");
/* End DO NOT EDIT SECTION generated by L-Edit */

if(LUpi_GetReturnCode())
{
LDialog_MsgBox("Error: Tcell failed to read parameters.");
return;
}
LUpi_SetReturnCode(iTmpUpiReturnCode);


/* TODO: Put local variables here. */
LObject IOrib;
int lstat = 1;
width *= 1000;
height *= 1000;
LFile pFile = LCell_GetFile( cellCurrent );
LLayer pLayer = LLayer_Find( pFile, "RIB1" );

/* TODO: Begin custom generator code.*/

LSelection_DeselectAll();
IOrib = LBox_New( cellCurrent, pLayer, 0,0,width,height );
lstat = LSelection_AddObject( IOrib );

/*LStatus output */
char Msg[256];
itoa (lstat,Msg,10);
LDialog_MsgBox( Msg );
/* End custom generator code.*/
}
extern "C" int UPI_Entry_Point(void)
{
test2_main();
return 1;
}
asc8y@virginia.edu
 

Re: Object Selection problems

Postby tu2011 » Tue Jun 26, 2012 11:09 pm

Hi Allen. The reason it is not working is because no selection function will work in a T-Cell environment as Selection functions only work on the visible cell and the objects that have been created by the T-Cell are actually in the auto-generated cell which is in memory and not the visible cell.

Tell me what you are trying to achieve and I can probably give you a better recommendation.
tu2011
 

Re: Object Selection problems

Postby asc8y@virginia.edu » Fri Jun 29, 2012 8:24 am

Thanks tu2011. I just wanted to do some general manipulations, for this particular case I wanted to merge a number of objects I had created during a for-loop.
-Allen
asc8y@virginia.edu
 

Re: Object Selection problems

Postby tu2011 » Sat Jun 30, 2012 12:18 am

Allen, I guess the first question is what you are doing that you need to merge the objects created in an autogenerated cell? Is it really necessary? But should you insist on doing this, the only way is to perform the Boolean or Grow/Shrink operation on the objects in the autogenerated cell. To do so, you would first collect the pointers to all the objects into an array. Then perform the Boolean operation by calling the function LCell_BooleanOperation(). Below is an example. Notice that I call the LBox_New() twice which creates two overlapping boxes. After the boolean OR operation, there is only one resulting box in the autogenerated cell. Of course, if you have more objects to merge, then L-Edit may take longer to create the autogenerated cell every time this T-Cell is instanced.


#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <string>

#define EXCLUDE_LEDIT_LEGACY_UPI
#include <ldata.h>


/* Begin -- Uncomment this block if you are using L-Comp. */
#include <lcomp.h>
/* End */

/* TODO: Put local functions here. */
void Box_Merge_main(void)
{
int iTmpUpiReturnCode = LUpi_GetReturnCode();
/* Begin DO NOT EDIT SECTION generated by L-Edit */
LCell cellCurrent = (LCell)LMacro_GetNewTCell();
LLayer Layer = LCell_GetParameterAsLayer(cellCurrent, "Layer");
double Length = LCell_GetParameterAsDouble(cellCurrent, "Length");
double Width = LCell_GetParameterAsDouble(cellCurrent, "Width");
/* End DO NOT EDIT SECTION generated by L-Edit */

if(LUpi_GetReturnCode())
{
LDialog_MsgBox("Error: Tcell failed to read parameters.");
return;
}
LUpi_SetReturnCode(iTmpUpiReturnCode);


/* Begin -- Uncomment this block if you are using L-Comp. */
LC_InitializeState();
LC_CurrentCell = cellCurrent;
/* End */

LObject paObject[2];
double dOffset = 5;
paObject[0] = LBox_New(cellCurrent, Layer, 0, 0, LC_Microns(Length), LC_Microns(Width));
paObject[1] = LBox_New(cellCurrent, Layer, LC_Microns(dOffset), LC_Microns(dOffset),
LC_Microns(Length + dOffset), LC_Microns(Width + dOffset));

LCell_BooleanOperation(cellCurrent, LBoolOp_OR, 0, paObject, 2, NULL, 0, Layer, LTRUE);

}
extern "C" int UPI_Entry_Point(void)
{
Box_Merge_main();
return 1;
}
tu2011
 


Return to UPI and TCL scripts

Who is online

Users browsing this forum: No registered users and 0 guests


Who is online

In total there are 0 users online :: 0 registered, 0 hidden and 0 guests (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 0 guests

Login Form