Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Drawing a ModelLine on Revit

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
578 Views, 2 Replies

Drawing a ModelLine on Revit

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.

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

You could draw all of the model lines before calling doc.Regenerate()
That should dramatically speed up the process
Message 3 of 3
jeremytammik
in reply to: Anonymous

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...

  • Use manual transaction mode.
  • Start a transaction, create the model lines, commit.
  • Encapsulate the entire operation within a 'using' statement.


I hope this helps.

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community