Hello,
On my project I need to draw lots of modelLines and, to do that, I utilised the follow code:
Line geomLine1 = Line.CreateBound(ptoinicial, PontoRet(ptoinicial, raio, ang));
XYZ origin = new XYZ(0, 0,ptoinicial.Z);
XYZ normal = new XYZ(0, 0, 1);
Plane geomPlane = doc.Application.Create.NewPlane(normal, origin);
SketchPlane sketch = SketchPlane.Create(doc, geomPlane);
ModelLine line = doc.Create.NewModelCurve(geomLine1, sketch) as ModelLine;
doc.Regenerate();
But, when I run the code, a process bar appears and indicates that Revit is "Automatically joining changed elements". This process is too slow, and I waste something like 10 minutes to draw the modelLines on a small project.
Is there any faster form to draw lots of modelLines that I can use?
Thanks,
Lucas Serra.
Dear Lucas,
Thank you for your query.
Cshha is correct.
You need to make sure that you are using manual transaction mode.
Otherwise, Revit will open, close and commit a new transaction for each line you create.
With manual transaction mode, you can create all the lines within one single transaction.
There is no need to call Regenerate at all, since that happens automatically when the transaction is committed.
The transaction should be ancapsulated in a 'using' statement to handle errors easily and gracefully:
http://thebuildingcoder.typepad.com/blog/2012/04/using-using-automagically-disposes-and-rolls-back.h...
I hope this helps.
Best regards,
Jeremy