Specify the voltage when creating an electrical system

Specify the voltage when creating an electrical system

maratalikuliev
Explorer Explorer
663 Views
6 Replies
Message 1 of 7

Specify the voltage when creating an electrical system

maratalikuliev
Explorer
Explorer

Hi, I'm trying to create an electrical circuit. I am trying to use the method ElectricalSystem.Create(Document, IList(ElementId), ElectricalSystemType) - https://www.revitapidocs.com/2021.1/66f12d78-a4ab-9b99-ef49-92c3a3e1835e.htm . But after the creation, the electric circuit has a voltage of 0. Can I specify the voltage level when creating an electric system. 

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;

namespace RevitPlugins
{
    [Regeneration(RegenerationOption.Manual)]
    [Transaction(TransactionMode.Manual)]
    public class Class : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document doc = uidoc.Document;
            Selection sel = uidoc.Selection;

            Reference reference = sel.PickObject(ObjectType.Element);
            FamilyInstance familyInstance = (doc.GetElement(reference) as FamilyInstance);
            ElectricalSystem system = familyInstance.MEPModel.GetElectricalSystems().FirstOrDefault();

            IList<ElementId> familyInstances = new List<ElementId>();
            ElementSet list_element = system.Elements;
            foreach (FamilyInstance family in list_element)
            {
                familyInstances.Add(family.Id);
            }

            ElectricalSystemType electricalSystemType = ElectricalSystemType.PowerCircuit;

            using (Transaction tr = new Transaction(doc, "Voltage change"))
            {
                tr.Start();
                doc.Delete(system.Id);
                ElectricalSystem electricalSystem = ElectricalSystem.Create(doc, familyInstances, electricalSystemType);
                tr.Commit();
            }
            return Result.Succeeded;
        }
    }
}

Sample code:

0 Likes
664 Views
6 Replies
Replies (6)
Message 2 of 7

ricaun
Advisor
Advisor

That's an old bug and if your family has an instance parameter for the voltage, ElectricalSystem.Create creates the voltage with zero.


In the next version of Revit (2025) this issue was fixed, check the link:

 

https://forums.autodesk.com/t5/revit-api-forum/newelectricalsystem-specify-voltage-amp-poles/td-p/62...

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 3 of 7

maratalikuliev
Explorer
Explorer

Thank you for your answer and saved my time searching for a solution, I will wait for the new version.

0 Likes
Message 4 of 7

maratalikuliev
Explorer
Explorer

Your thought about the fact that the voltage is set for families with a voltage parameter by type led me to the following thought. I have a 380V circuit consisting of elements with a voltage of one instance. I remove the electrical circuit, add an instance with voltage by type to it, add an electrical circuit to the electrical equipment. Next, I remove the family from the electrical circuit with the voltage parameter by type. The electrical circuit keeps the voltage level. My task was to change the voltage of the existing circuit

 

 

0 Likes
Message 5 of 7

ricaun
Advisor
Advisor

I test that a long time ago and have some issues, if you remove the family with the voltage type reference to voltage goes to zero.

 

https://youtu.be/6uwDFl9lJTI?si=B3_FZxTIWFLmHlpO

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 6 of 7

maratalikuliev
Explorer
Explorer

I have encountered the same problem with the usual creation of a circuit without connecting it to electrical equipment. But if I connect the circuit to electrical equipment and then remove the element with the voltage parameter by type, then the voltage of the other elements is not equal to 0, but remains the same. in the fourth message, I attached a video

0 Likes
Message 7 of 7

ricaun
Advisor
Advisor

At least when I tested if the user removed the circuit from the panel the voltage went to zero.

 

I didn't find safe enough to use 😑

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes