I coming from VBA to C# and I am having trouble figuring out how to create detail lines. Can someone show me a few lines of code as to how to create a detail line. I am trying to write an application macro inside Revit. Your patience and help will be most appreciated.
Solved! Go to Solution.
Solved by IbrahimNaeem. Go to Solution.
Hi Stanley,
I don't know which Revit Version you use but I give here a piece of code I did, tested and works fine:
XYZ P1 = new XYZ(x1,y1,z1); XYZ P2 = new XYZ(x2,y2,z2); Line L1 = Line.CreateBound(P1,P2); doc.Create.NewDetailCurve(vd,L1); // where vd is the view you need to draw your detail lines in // where doc is the active document
Hope this helps.
Thanks, Ibrahim Naeem
- Line line = Line.CreateBound(start, end);
- DetailLine detailLine = (DetailLine) doc.Create.NewDetailCurve(view, line );
I try to Create 2D Detail Line from Pipe Slope but Can't create. Can you help me?
Thanks!
Hi @bimsmart.hql ,
a Z difference is not allowed for a detail line, simply set the z-value for each point to zero prior to creating the line.
start = new XYZ(start.X,strat.Y,0);
end = new XYZ(end.X,end.Y,0);
hope this helps.
Hi@landis.mark , Here's a code sample on how to achieve this
//field definition
GraphicsStyle _gstyle;
internal static void setLineStyle(View vDraftingv, Line line, Document doc)
{
if (null == _gstyle || !_gstyle.IsValidObject)
{
var gstyles = (new FilteredElementCollector(doc)).OfClass(typeof(GraphicsStyle)).Cast<GraphicsStyle>().ToList();
_gstyle = gstyles.Where(x => x.GraphicsStyleType == GraphicsStyleType.Projection).FirstOrDefault(x => x.Name.ToLower() == "<wide lines>" /*or any name you wish to use*/);
}
DetailCurve dc = doc.Create.NewDetailCurve(vDraftingv, line);
if (_gstyle != null && _gstyle.IsValidObject) dc.LineStyle = _gstyle;
}
Hope this helps.
Ibrahim Naeem