THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/11/2009 at 15:58, xxxxxxxx wrote:
Thanks for your reply Robert.
I have successfully created a function that hides one side of the object.. the problem I am having is that I would like to store any current selection that exists and return that selection when the user shows the hidden side again. The reason I want this to happen is that I do not want users to even be aware that a selection was made to hide half of the model. Here's what I have so far:
PolygonObject* objPoly;
objPoly=(PolygonObject* )obj;
if (!objPoly->IsInstanceOf(Opolygon))
return false;
ModelingCommandData mdat;
BaseSelect *selected = objPoly->GetPolygonS();
if (!selected) return FALSE;
BaseSelect *currentSel = objPoly->GetPolygonS();
if (!currentSel) return FALSE;
BaseDocument * doc=obj->GetDocument();
LONG lngI=0, lngJ=0, lngK=0, lngL=0;
LONG lngPolygonCount=objPoly->GetPolygonCount();
LONG lngSymPlane = data->GetReal(SYMMETRY_PLANE);
LONG lngMirroredSide = data->GetReal(MIRRORED_SIDE);
LONG lngSize=sizeof(LONG)*lngPolygonCount;
LONG * selectionIndex;
selectionIndex = (LONG* )GeAlloc(lngSize);
Vector * arrPoints=objPoly->GetPointW();
CPolygon * arrPolygons=objPoly->GetPolygonW();
CPolygon * hiddenPolygons=objPoly->GetPolygonW();
mdat.mode = MODIFY_POLYGONSELECTION;
mdat.doc = doc;
mdat.bc = data;
mdat.op = objPoly;
// Find currently selected polygons.
for (lngJ=0; lngJ<lngPolygonCount; lngJ++)
{
if (currentSel->IsSelected(lngJ))
{
selectionIndex[lngK]= lngJ;
GePrint("selectionIndex[" + LongToString(lngK) + "] =" + LongToString(lngJ));
lngK++;
}
else
{
return TRUE;
}
}
if (data->GetBool(HIDE_SIDE) && data->GetLong(SIDE_HIDDEN)==HIDE_A)
{
//Check to see which polys will be hidden
selected->DeselectAll();
SendModelingCommand(MCOMMAND_UNHIDE, mdat);
for (lngI=0;lngI<lngPolygonCount;lngI++)
{
if (PolyOnEditableSide(arrPoints, arrPolygons, lngI, lngSymPlane, lngMirroredSide, lngOldPointCount, lngOldPolygonCount))
{
selected->Select(lngI);
//GePrint("Polygon " + LongToString(lngI) + " was selected.");
//GePrint("Polys selected =" + LongToString(selected->GetCount()));
}
}
SendModelingCommand(MCOMMAND_HIDESELECTED, mdat);
return TRUE;
}
else if (data->GetBool(HIDE_SIDE) && data->GetLong(SIDE_HIDDEN)==HIDE_B)
{
//Check to see which polys will be hidden
selected->DeselectAll();
SendModelingCommand(MCOMMAND_UNHIDE, mdat);
for (lngI=0;lngI<lngPolygonCount;lngI++)
{
if (!PolyOnEditableSide(arrPoints, arrPolygons, lngI, lngSymPlane, lngMirroredSide, lngOldPointCount, lngOldPolygonCount))
{
selected->Select(lngI);
//GePrint("Polygon " + LongToString(lngI) + " was selected.");
//GePrint("Polys selected =" + LongToString(selected->GetCount()));
}
}
SendModelingCommand(MCOMMAND_HIDESELECTED, mdat);
return TRUE;
}
else
{
//GePrint("i = " + LongToString(i));
SendModelingCommand(MCOMMAND_UNHIDE, mdat);
selected->DeselectAll();
for (lngL=0;lngL<lngK; lngL++)
{
currentSel->Select(selectionIndex[lngL]);
GePrint("Selecting Polygon: " + LongToString(selectionIndex[lngL]));
}
return TRUE;
}
as you can see below the // Find currently selected polygons.
I search through all of the polygons and determine which ones are selected, then at the bottom when the UNHIDE is enabled,
I attempt to recreate the selection that was stored. For some reason, lngK is coming out 0. I think that this is because the function is called from the Message() and is called again after the new selection is hidden and thus no polygons are selected. I think this is why lngK keeps returning 0.. but I can't figure out how to get around this.
I know that was a mouthful but can anyone please help me. 
Thanks
~Shawn