public void CreateCasualSelection()
{
Document doc = _revit.ActiveDocument;
SelElementSet elems = doc.Selection.Elements;
ElementSetIterator iter = elems.ReverseIterator();
List<Autodesk.Revit.Elements.Panel> panels = new List<Autodesk.Revit.Elements.Panel>();
iter.Reset();
while (iter.MoveNext())
{
Element elem = iter.Current as Element;
if (elem is Autodesk.Revit.Elements.Panel)
{
Autodesk.Revit.Elements.Panel elemPanel = elem as Autodesk.Revit.Elements.Panel;
panels.Add(elemPanel);
}
}
elems.Clear();
int NumPanels = panels.Count;
double perc = _receivePercTextBox / 100;
double PercPanels = NumPanels * perc;
for (int j = 0; j < 6; j = j + 1)
{
NumeroCasuale nums = new NumeroCasuale();
SelElementSet update = _revit.Create.NewSelElementSet();
for (int i = 0; i < PercPanels; i= i + 1)
{
//Random casual = new Random(unchecked((int)(DateTime.Now.Ticks >> i)));
Random casual = new Random();
int numCasual = casual.Next(0, casual.Next(NumPanels));
int numGood;
while (!nums.NumberIsOK(numCasual))
{
numCasual = casual.Next(0, casual.Next(NumPanels));
}
numGood = numCasual;
Autodesk.Revit.Elements.Panel panel = panels[numGood];
update.Add(panel);
}
gruppo[j] = update;
}