namespace RevitAddin61 { [Transaction(TransactionMode.Manual)] public class Command : IExternalCommand { public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; Reference myRef = uidoc.Selection.PickObject(ObjectType.Face); Element e = doc.GetElement(myRef); GeometryObject geo = e.GetGeometryObjectFromReference(myRef); Face f = geo as Face; EdgeArrayArray loops = f.EdgeLoops; foreach (EdgeArray loop in loops) { foreach (Edge edge in loop) { Curve curve = edge.AsCurve(); XYZ p = curve.GetEndPoint(0); XYZ q = curve.GetEndPoint(1); Line line = Line.CreateBound(p, q); } } return Result.Succeeded; } } }
Hello friends i want to create detail lines from selected face
Line line = Line.CreateBound(p, q);
Command doesn't work for me
How can i do this.?
Thanks in advance....
Solved! Go to Solution.
Solved by Revitalizer. Go to Solution.
Solved by Revitalizer. Go to Solution.
Hi desdinova,
for creating DetailCurves, you would need a proper view since they are view-depending.
You may use ModelCurves instead.
See TBC for creating ModelCurves examples, e.g.:
Revitalizer
using (Transaction t = new Transaction(doc, "Detail Lines")) { t.Start(); Line line = Line.CreateBound(x1, x2); DetailCurve detailCurve = doc.Create.NewDetailCurve(doc.ActiveView, line); t.Commit(); }
Thank you.
The code above solved my problem.
But now i want to set linestyle for my detail curve.
Is it possible because the code draw thin lines i want to draw overhead lines
Hi desdinova,
yes, that's possible.
Just assign a GraphicsStyle object to the detailCurve.LineStyle property.
You will find a collection of proper ElementIds this way:
ICollection<ElementId> styleIDs = detailCurve.GetLineStyleIds();
Just get the relating Elements by those IDs, cast them to GraphicsStyle objects.
By comparing their names, you will get the one you want.
Note that each GraphicsStyle also has a GraphicsStyleType property, so there may be two of the same name of which you can use the one with GraphicsStyleType.Projection.
That's all.
Revitalizer
ICollection<ElementId> styleIDs = detailCurve.GetLineStyleIds(); foreach (ElementId id in styleIDs) { Element elem = doc.GetElement(id); if(elem.Name=="<Overhead>") { GraphicsStyle egs = elem as GraphicsStyle; detailCurve.LineStyle = egs; } }
hi Revitalizer
Thank you for your reply.
now i want to draw detailCurve in under the floor plan
How can i do that.?
Hi desdinova,
what do you mean saying "in under" the floor plan ?
Do you mean that you want to draw them in the ceiling plan belonging to the next lower level ?
So just use that view for drawing the DetailCurves.
Revitalizer
Hi Revitalizer,
Your tool works fine for me at "System Families", but when I am trying this on "Loadable families" like Duct Fittings it doesn't draw the lines. I can pick a face of an elbow but the tool will not draw the lines. When I pick a straight duct the lines will appear. Do you have any solution for my problem?
Hi,
an elbow has a curved geometry, so no straight lines but curves.
The code creates new lines using the end points of an edge.
You could use the edge curves directly.
After creating ModelCurves, you could use Document.ConvertModelToDetailCurves() to display the projected curves in a given view.
https://forums.autodesk.com/t5/revit-api-forum/projection-transformation/m-p/9119247
Revitalizer
Can't find what you're looking for? Ask the community or share your knowledge.