//Credits https://github.com/mcneel/rhino.inside-revit/blob/5701bd32fabfdc24c7dd4248c1ab9339f7c36148/src/RhinoInside.Revit.GH/Components/Element/DirectShape/ByCurve.cs		
    
    public void CurveDirectShape()
		{
			
			UIDocument uidoc = this.ActiveUIDocument;
			Document doc = uidoc.Document;
			
			XYZ pt0 = new XYZ(0,0,0);
			XYZ pt1 = new XYZ(10,10,0);
			XYZ pt2 = new XYZ(20,0,0);
			XYZ pt3 = new XYZ(40,10,0);
			
			List<Curve> profile = new List<Curve>();

			
			profile.Add(Line.CreateBound(pt0, pt1));
			profile.Add(Line.CreateBound(pt1, pt2));
			profile.Add(Line.CreateBound(pt2, pt3));
			
			WireframeBuilder builder = new WireframeBuilder();
			
			builder.AddCurve(Line.CreateBound(pt0, pt1));
			builder.AddCurve(Line.CreateBound(pt1, pt2));
			builder.AddCurve(Line.CreateBound(pt2, pt3));
			
			using (Transaction t =  new Transaction(doc, "a")){
				
			t.Start();
			
				DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));
				ds.SetShape(profile.ToArray().OfType<GeometryObject>().ToList());
				
				DirectShape dsWireframe = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));
				ds.SetShape(builder);
				
			t.Commit();
			
			TaskDialog.Show("r", ds.Id.ToString());
			}		
		}