creating detail lines

creating detail lines

stanleypaseur
Contributor Contributor
12,496 Views
8 Replies
Message 1 of 9

creating detail lines

stanleypaseur
Contributor
Contributor

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.

0 Likes
Accepted solutions (2)
12,497 Views
8 Replies
Replies (8)
Message 2 of 9

IbrahimNaeem
Advocate
Advocate
Accepted 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  

Message 3 of 9

Anonymous
Not applicable
Accepted solution

Thank you it work well for me

0 Likes
Message 4 of 9

Anonymous
Not applicable

Hi  IbrahimNaeem.

bimsmarthql_1-1638409818831.png

 

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

0 Likes
Message 5 of 9

IbrahimNaeem
Advocate
Advocate

Hi @Anonymous ,

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.

0 Likes
Message 6 of 9

Anonymous
Not applicable

Hi @IbrahimNaeem.

Thank you it work well for me!

0 Likes
Message 7 of 9

landis.mark
Contributor
Contributor

How do I set a specific Line Style to my detail line as I create it?

0 Likes
Message 8 of 9

IbrahimNaeem
Advocate
Advocate

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

Message 9 of 9

landis.mark
Contributor
Contributor

Thanks, that was enough to figure out what I needed.

0 Likes