Revit line load with c#


I am trying to make a node in dynamo with the ZeroTouch that creates a line load for a structural element in Revit. The same result as in this post: Revit Line loads through Dynamo but with c#.

I don’t have any experience with c# (or coding) but i watched some tutorials for ZeroTouch.

I know i have to define variables and objects, but i am not sure how. This is my script so far:

using Autodesk.DesignScript.Geometry;
using Autodesk.DesignScript.Runtime;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Structure;
using Revit.Elements;
using RevitServices.Persistence;

namespace ClassLibrary6
    public class Structure
        private Structure()
        public static LineLoad Create(Document aDoc, AnalyticalModelSurface host, int curveIndex, XYZ forceVector1, XYZ momentVector1, LineLoadType symbol)
            aDoc = DocumentManager.Instance.CurrentDBDocument;

            Autodesk.Revit.DB.Structure.AnalyticalModel Input;
            Input = host.
            XYZ forceVector;
            XYZ momentVector;

            forceVector = forceVector1.
            momentVector = momentVector1.
            return LineLoad

I am missing a lot of input here, so if anyone can point me in the right direction that would be great!

I don’t think you are creating it. Most structural framing has analytical lines you just have to turn them on.
Once you get all the structural framing using the filtered element collector you can iterate over it and get the analytical model like this using a foreach or lambda expression.

// Here is how to get the Analytical line. 
 FamilyInstance familyInstance = e as FamilyInstance;
AnalyticalModel analyticalModel = familyInstance.GetAnalyticalModel();
Curve analyticalCurve = analyticalModel.GetCurve();
XYZ pointStart = analyticalCurve.GetEndPoint(0);
XYZ pointEnd = analyticalCurve.GetEndPoint(1);


One last thing I’d like to add. If you don’t have a background in programming I’d suggest maybe using python instead of C#.
With python you don’t have to install your dll to dynamo and compile your code each time it changes. Python is also a simpler language to get started with.
I love C# it was one of the first languages I learned but it’s really ment for application development or custom add-ins using Revit with the API. I would recommend that if you are a beginner to save yourself the trouble of having to go through extra steps to accomplish a simple task and stick to native dynamo nodes and python.

1 Like

Here is a nice example of load line using Python node.

1 Like

Thank you for the advice, Danny!

I managed to create the line load with Python.

1 Like