Message 1 of 3
Not applicable
10-14-2015
10:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I am trying to programmatically create grids with the attached code fragment. This code fragment is now working fine, but the matter here is that the grids are all generated at one time when the command is completed.
Is there any way to dynamically generate grids one by one while the iteration still moving?
This is possible if I show a Message Box on each transaction, but this way I need to manually close the Message Box for every transaction then.
Looking forward for a solution
My code
ElementCategoryFilter categoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Lines);
IList<Element> allLines = new FilteredElementCollector(doc).WherePasses(categoryFilter).WhereElementIsNotElementType().ToElements();
foreach (Element e in allLines)
{
LocationCurve locationCurve = e.Location as LocationCurve;
foreach (Parameter param in e.Parameters)
{
if (param.Definition.Name.Equals("Line Style") && param.AsValueString().Equals("Hz_Grid"))
{
using (Transaction tran = new Transaction(doc, "Tạo Lưới"))
{
Line line = Line.CreateBound(locationCurve.Curve.GetEndPoint(0), locationCurve.Curve.GetEndPoint(1));
tran.Start();
doc.Create.NewGrid(line);
tran.Commit();
}
}
}
}Thank you
Nguyen Duy Hoa
Solved! Go to Solution.