Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

creating detail lines

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
stanleypaseur
9895 Views, 8 Replies

creating detail lines

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.

8 REPLIES 8
Message 2 of 9

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
in reply to: IbrahimNaeem

Thank you it work well for me

Message 4 of 9
bimsmart.hql
in reply to: IbrahimNaeem

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!

Message 5 of 9
IbrahimNaeem
in reply to: bimsmart.hql

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.

Message 6 of 9
bimsmart.hql
in reply to: IbrahimNaeem

Hi @IbrahimNaeem.

Thank you it work well for me!

Message 7 of 9
landis.mark
in reply to: IbrahimNaeem

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

Message 8 of 9

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
in reply to: IbrahimNaeem

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community