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?
Solved! Go to Solution.
Solved by dirk.neethling. Go to Solution.
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
Cheers,
Jeremy
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
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
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?
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
Hello Jeremy,
I changed to a plan view, and ran the method successfully.
Thanks for the pointer! (is that better?)
Greetings, Dirk
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
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
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
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
I published an edited version of the important points now:
Cheers,
Jeremy