draw curve in ActiveUIDocument.Document using IList<XYZ>

draw curve in ActiveUIDocument.Document using IList<XYZ>

dirk.neethling
Advocate Advocate
5,102 Views
13 Replies
Message 1 of 14

draw curve in ActiveUIDocument.Document using IList<XYZ>

dirk.neethling
Advocate
Advocate

I'm trying to draw a contigous curve in an ActiveUIDocument.Document, using a List of XYZ objects. Most examples draw a curve in a FamilyDocument, but I could not adapt it for an ActiveUIDocument.Document. Is it necessary to create a plane for such a curve?

 

0 Likes
Accepted solutions (1)
5,103 Views
13 Replies
Replies (13)
Message 2 of 14

jeremytammik
Autodesk
Autodesk

Dear Dirk,

 

Yes.

 

You can create a model curve or a detail curve, and both reside on a sketch plane.

 

If you care about efficiency, you might care to reuse the sketch plane as much as possible.

 

Note that some existing samples create a new sketch plane for each individual curve, which is not a nice thing to do.

 

The Building Coder provides a number of samples, e.g.:

 

 

Also included in The Building Coder samples:

 

https://github.com/jeremytammik/the_building_coder_samples

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...

 

Cheers,

 

Jeremy

 



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

Message 3 of 14

dirk.neethling
Advocate
Advocate
Thanks for answering Jeremy. Unfortunatly the samples do not compile in Revit 2016. I'm struggling to reconfigure the code.

Using Model Curve Creator, for example here:

Transform tv = Transform.GetTranslation(v);
curve = curve.GetTransformed(tv);

and here:

foreach (GeometryObject obj in e.Objects)

Dirk
0 Likes
Message 4 of 14

jeremytammik
Autodesk
Autodesk

Dear Dirk,

 

That is not true.

 

The Building Coder samples are completely up to date and compile with zero errors and zero warnings.

 

Furthermore, all migrations of Revit add-ins are very straight forward and extensively documented by The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/migration

 

There is no reason for you to struggle at all.

 

Unless you enjoy it, of course.

 

Relax and enjoy.

 

Cheers,

 

Jeremy



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

Message 5 of 14

dirk.neethling
Advocate
Advocate

ModelCurveCreator.png

0 Likes
Message 6 of 14

jeremytammik
Autodesk
Autodesk

You seem to be looking at version 2011.0.69.0 of The Building Coder samples.

 

From the original post, in May 2010.

 

Cool.

 

If you insist, so be it.

 

You can also look at the other releases on GitHub:

 

https://github.com/jeremytammik/the_building_coder_samples/releases

 

Or just grab the current Revit 2016 master from 

 

https://github.com/jeremytammik/the_building_coder_samples

 

Cheers,

 

Jeremy



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

Message 7 of 14

dirk.neethling
Advocate
Advocate

I used your code from https://github.com/jeremytammik/the_building_coder​_samples, extracting from CmdDetailCurves.cs.

I encapsuled it in a method:

 

static void drawArc(Document doc, Autodesk.Revit.DB.View view)

 

with

 

UIApplication uiApp = commandData.Application;

Document doc = uiApp.ActiveUIDocument.Document;

Autodesk.Revit.DB.View view = doc.ActiveView;

 

it cracks at:

// Create a DetailLine element using the

// newly created geometry line and sketch plane

DetailLine line = creDoc.NewDetailCurve(view, geomLine) as DetailLine;

 

with:

+  exc {"View is not valid for detail line creation.\r\nParameter name: view"} System.Exception {Autodesk.Revit.Exceptions.ArgumentException}

 

 

what am I doing wrong?

0 Likes
Message 8 of 14

jeremytammik
Autodesk
Autodesk

Dear Dirk,

 

I am glad that you have it working now.

 

Thank you also for your overwhelming appreciation.

 

The Revit API is a very simple API.

 

As I keep pointing out, the Revit product is much more complex and harder to use.

 

You apparently need to practice the product side of things a bit before diving deeper into the API.

 

One basic piece of end user knowledge is that detail elements can only be added to plan views.

 

Probably your current view is not a plan view.

 

I hope this helps.

 

Cheers,

 

Jeremy



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

Message 9 of 14

dirk.neethling
Advocate
Advocate

Hello Jeremy,

 

I changed to a plan view, and ran the method successfully.

Thanks for the pointer! (is that better?)

Greetings, Dirk

0 Likes
Message 10 of 14

dirk.neethling
Advocate
Advocate

Hello Jeremy,

 

I noticed that when I switch back to 3D view, the curve is no longer visible. Do I need to make another call to make it visible in 3D View?

Greetings, DIrk

0 Likes
Message 11 of 14

jeremytammik
Autodesk
Autodesk

Dear Dirk,

 

Thank you for your appreciation. 

 

Much better indeed.

 

Afaik, detail curves are never visible in 3D.

 

You have to use model curves for that.

 

I am not a product usage expert, though.

 

You should either be one yourself or have one to consult.

 

Cheers,

 

Jeremy



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

Message 12 of 14

dirk.neethling
Advocate
Advocate
Accepted solution

Hello Jeremy,

 

OK, CreateModelLine was my starting point,

 

l = Creator.CreateModelLine(doc, xyz_prev, xyz);

 

but I wanted to add color and was looking for something more elegant, that's why I tried CmdDetailCurves.

 

I am trying to draw an axis along which I can string Tunnel elements. So I reverted back to CreateModelLine (see attachment), which seems to work fine.

 

Thanks for the support!

 

Greetings, Dirk

 

 

0 Likes
Message 13 of 14

jeremytammik
Autodesk
Autodesk

Dear Dirk,

 

Again, an end user product information: you can use the view graphics and visibility settings to control the model line appearance, e.g. colour and line type.

 

Cheers,

 

Jeremy



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

0 Likes
Message 14 of 14

jeremytammik
Autodesk
Autodesk

I published an edited version of the important points now:

 

http://thebuildingcoder.typepad.com/blog/2016/03/index-reloading-curves-distance-and-deleting-prints...

 

Cheers, 

 

Jeremy



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