Home .NET Single line diagrams in Revit

Single line diagrams in Revit

by admin

Single line diagrams in Revit
Revit is a software package that implements the principle of building information modeling.The program was originally designed for architects.Now more and more companies require engineers to be proficient in Revit when hiring. Autodesk Revit provides a powerful .NET API which allows you to develop your own applications to solve various tasks. In this article, I want to share my experience in creating single-line diagrams in Revit.

The main benefits of Revit for the engineer are :
– work with actual layouts;
– collaboration of several engineers in a single file;
– control of the crossing of utilities;
– assignment exchange;
– creating automatically updated specifications.
Revit also allows you to design electrical systems and calculate loads in tabular form. The disadvantage is that it is not possible to make calculations, select equipment and draw schemes in accordance with the regulatory documents in force in the territory of the Russian Federation. Creating single-line diagrams is quite a labor-intensive procedure, which takes a lot of time.
When I worked in Autocad, I used an Excel spreadsheet to calculate: I entered the wattage of connected equipment, names, locations, type, lengths, and many more parameters, did the calculation, and then drew the schematics with the plugin for Autocad
Now, when working with Revit, you can get all this data from the BIM model. For example, this plugin gets the following information :
– Switch number;
– Electrical Loads;
– Voltage;
– Number of poles;
– Power Factor;
– Cable type;
– Classification of electrical loads;
– Neutral conductor cross-section;
– The length of the cable line.
The rest of the information is calculated based on the parameters received and entered by the user.
The work of the plugin consists of three steps :
1) Getting the necessary data from the BIM model and loading it into a form for editing;
2) Editing parameters by the user;
3) Circuit Creation.
The plugin can be downloaded at link
To retrieve the parameters of electrical systems, access the active document :

UIApplication uiapp = commandData.Application;UIDocument uidoc = uiapp.ActiveUIDocument;Application app = uiapp.Application;Document doc = doc.Document;

Next, we extract the required parameters from the BIM model. In this example we will consider how to retrieve circuit parameters (number, power factor, cable type), as well as cable core material from cable line settings. The search of the required parameters is done by ID with the help of the list BuiltInParameters This way of finding the parameter will not depend on Revit localization.

//We select the electrical circuits related to the shield "SCHS"ParameterValueProvider provider= new ParameterValueProvider(new ElementId((int)BuiltInParameter.RBS_ELEC_CIRCUIT_PANEL_PARAM));FilterStringRule rule = new FilterStringRule(provider, new FilterStringEquals(), "SHC", true);ElementParameterFilter filter = new ElementParameterFilter(rule);ICollection<Element> docCircuits =(new FilteredElementCollector(doc)).OfCategory(BuiltInCategory.OST_ElectricalCircuit).WherePasses(filter).ToArray();foreach (Element docCircuit in docCircuits){//Chain numbernum = docCircuit.get_Parameter(BuiltInParameter.RBS_ELEC_CIRCUIT_NUMBER)?.Element.Name;//Power FactorpowerFactor =docCircuit.get_Parameter(BuiltInParameter.RBS_ELEC_POWER_FACTOR)?.AsValueString();//Cable typecableType = docCircuit.get_Parameter(BuiltInParameter.RBS_ELEC_CIRCUIT_WIRE_TYPE_PARAM)?.AsValueString();//Core materialElement wireType = new FilteredElementCollector(doc).OfClass(typeof(WireType)).FirstOrDefault<Element> (e => e.Name.Equals(cableType));string coreMaterial = wireType.get_Parameter(BuiltInParameter.RBS_WIRE_MATERIAL_PARAM).AsValueString();}

Once we have the required parameters we can start creating the schema. We create a transaction and insert the elements of the schema into the file. By the way, the unit of measure is feet, so when inserting elements you should not forget about it.

using (Transaction tx = new Transaction(doc)){tx.Start("Creating a single-line diagram");double xCoord = 0;// insert branch linesforeach (Circuit circuit in panel.circuits){//Get the family from the active document by name.FamilySymbol lineSymbol = FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(q => q.Name == "SLD_AB").First() as FamilySymbol;//Convert insertion point coordinates from millimeters to feetXYZ coords = new XYZ(xCoord, 0, 0).ToFeets();//Insert a family named SLD_AB.FamilyInstance line = doc.Create.NewFamilyInstance(coords, lineSymbol, uidoc.ActiveView);//Get all the parameters of the familyParameterSet parametersLineOut = line.Parameters;//Write the value in the family parameterforeach (Parameter param in parametersLineOut){switch (param.Definition.Name){case "Group number": param.Set(circuit.number); break;case "CableType": param.Set(circuit.cableType); break;case "Power Factor": param.Set(circuit.powerFactor); break;}}xCoord = xCoord + 25;}tx.Commit();}

That’s it, the circuit is ready!

You may also like