NewElectricalSystem Specify Voltage & Poles

NewElectricalSystem Specify Voltage & Poles

bxw
Enthusiast Enthusiast
5,826 Views
45 Replies
Message 1 of 46

NewElectricalSystem Specify Voltage & Poles

bxw
Enthusiast
Enthusiast

 

I'm trying to create an electrical system on an element when the Voltage & Poles parameters are instance parameters.  The following works when those parameters are Type parameters, however the voltage is set to 0V when voltage is an instance parameter.  The Voltage parameter on an electrical system is read only.  Is there a way to do this?  

 

//Works when Voltage & Poles are type parameters, returns 0V & 1 Pole when Volts & Poles are instance parameters

// es is an electrical fixture 

newCircuit = doc.Create.NewElectricalSystem(es, ElectricalSystemType.PowerCircuit);

 

 

In the UI when Voltage & Poles are instance parameters you have this dialog to choose the value. 

 

 

specifyCircuitInformation.PNG

 

 I would like to use the value of the Voltage & Poles instance parameters. I have looked around the MEPmodel, ConnectorManager, etc but can't seem to find a way to specify the voltage & poles?  

 

 

Any input would be appreciated.  Thanks.

 

 

0 Likes
5,827 Views
45 Replies
Replies (45)
Message 2 of 46

Anonymous
Not applicable

I tried what you did but I also got stucked.  At the end, I just use type parameter and make different types within the family.  Then I have the API to select which type within the family to use based its name(assuming you have the voltage and poles in the name).Let me know if you have a better way.

 

Tak Au, 

0 Likes
Message 3 of 46

jeremytammik
Autodesk
Autodesk

Dear Bxw and Tak Au,

 

Thank you for your query.

 

The voltage and number of poles are defined by the connector properties.

 

Look at the Revit API help under Model the Design > Revit Families > Connectors > Connector Properties:

 

http://help.autodesk.com/view/RVT/2017/ENU/?guid=GUID-3DE410FC-7BB7-44FD-B75E-A02C4F42C1AD

 

You should be able to navigate to the connector you are interested in and see these properties in RevitLookup:

 

https://github.com/jeremytammik/RevitLookup

 

I cannot tell you off-hand whether these values are read-only or not, but RevitLookup can and will, and then you will know both that and the proper path to access them

 

Another useful too for exploring element properties and parameters is the BipChecker.

 

https://github.com/jeremytammik/BipChecker

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 4 of 46

bxw
Enthusiast
Enthusiast

Jeremy,

 

Thanks for the reply.  To clarify the connector has valid values for Voltage & Poles however the NewElectricalSystem method creates a system with 0V if the voltage parameter is an instance parameter.  It works correctly if the voltage parameter is a type parameter.  Here is a screen cast showing first creating the power circuit through the Revit UI,then using the API Power Circuit sample.  I demonstrate using a device with Voltage asigned to a type parameter and then with an instance parameter.  

 

On the new Electrical System:

Voltage - RBS_ELEC_VOLTAGE is read only.  

Poles - RBS_ELEC_NUMBER_OF_POLES is read only.

 

As far as i can tell there is no implementation of the 'Specify Circuit Information' or equivalent in the Revit API.  

 

specifyCircuitInformation.PNG

 

Thanks,

 

Ben

 

0 Likes
Message 5 of 46

alexander.tomkeyev
Participant
Participant

Ben, It seems that there is a bug in the API that prevents it from reading instance parameters when creating an electrical system. Of course you could change all your families and use instance parameters instead and reconfigure every instance in the model, but it is a ton of work.

 

I believe I've found a workaround that is pretty reliable, at least in R2016.

The idea is to create a mock family with a unique name with several types that will have corresponding voltage-pole number combinations as type parameters. So when you want to create a new electrical system, you follow these steps:

 

1. Read voltage and pole number from your existing device.

2. Find a corresponding family symbol (family type) that has the same voltage and number of poles as type parameters

3. Create a temporary instance using that symbol.

4. Create a new electrical system with that temporary device. This ensures that the new system doesn't have 0 V voltage.

5. Add your existing device to that circuit.

6. Important - assign a panel to this newly created electrical system.

7. After that you can disconnect the temporary device from the electrical system.

8. Delete the temporary instance

 

Just make sure that you assign a panel before disconnecting that temp device. Probably you'll need more temp families for non-power circuits, but the idea is the same.

Hope this helps.

-Alex

Message 6 of 46

Anonymous
Not applicable

Good Morning.
I need to edit the voltage and number of poles.
Does anyone have code that works to help me?

 

My code:

 

Public Function Execute(commandData As ExternalCommandData, ByRef message As String, elements As ElementSet) As Result Implements IExternalCommand.Execute

Dim BuiltInCategorys As New List(Of BuiltInCategory)
Dim eKeyWorkReferences As eKeyWorkReferences
Dim ekeyworkreference As eKeyWorkReference
Dim Document As Document
Dim FamilyInstance0 As FamilyInstance = Nothing
Dim FamilyInstance1 As FamilyInstance = Nothing
Dim Parameters As List(Of Parameter)
Dim Parameter0 As Parameter
Dim Circuit As ElectricalSystem
Dim Panel As FamilyInstance
Dim Connectors As List(Of Connector)
Dim Connector As Connector = Nothing
Dim ElementSet As ElementSet

'Obtem o documento
Document = commandData.Application.ActiveUIDocument.Document

'Filtro
With BuiltInCategorys
.Add(BuiltInCategory.OST_ElectricalFixtures)
.Add(BuiltInCategory.OST_ElectricalEquipment)
.Add(BuiltInCategory.OST_LightingFixtures)
.Add(BuiltInCategory.OST_LightingDevices)
.Add(BuiltInCategory.OST_CommunicationDevices)
.Add(BuiltInCategory.OST_DataDevices)
.Add(BuiltInCategory.OST_FireAlarmDevices)
.Add(BuiltInCategory.OST_NurseCallDevices)
.Add(BuiltInCategory.OST_SecurityDevices)
.Add(BuiltInCategory.OST_TelephoneDevices)
'.Add(BuiltInCategory.OST_ConduitFitting)
'.Add(BuiltInCategory.OST_Conduit)
End With

'Solicita a seleção de elementos
eKeyWorkReferences = Engine.eRevitInterface.PickObjects(commandData, "Selecione os elementos",, BuiltInCategorys)


'Solicita a seleção do quadro
ekeyworkreference = Engine.eRevitInterface.PickObject(commandData, "Selecione o quadro",, BuiltInCategorys)


Panel = Document.GetElement(ekeyworkreference.Reference.ElementId)


Dim connectorSet As ConnectorSet = New ConnectorSet()

Dim csi As ConnectorSetIterator = Nothing

'Abre transação
Using Transaction As New eTransaction(Document)

Transaction.Start("Test", True)

For Each id As ElementId In eKeyWorkReferences.References.GetElementIds

FamilyInstance0 = Document.GetElement(id)

'--

Parameters = FamilyInstance0.GetParameters("Slot 1_Classificação de carga")

Parameter0 = Parameters(0)

Parameter0.SetValueString("Other")

'--

Parameters = FamilyInstance0.GetParameters("Slot 1_Fator de potência")

Parameter0 = Parameters(0)

Parameter0.SetValueString("0.85")

'--

Parameters = FamilyInstance0.GetParameters("Slot 1_Número de pólos")

Parameter0 = Parameters(0)

Parameter0.SetValueString("1")

'--

Parameters = FamilyInstance0.GetParameters("Slot 1_Potência ativa (W)")

Parameter0 = Parameters(0)

Parameter0.SetValueString("100")

'--

For Each ww As ElementId In FamilyInstance0.GetSubComponentIds

FamilyInstance1 = Document.GetElement(ww)

If IsNothing(FamilyInstance1.MEPModel) = False Then

If IsNothing(FamilyInstance1.MEPModel.ConnectorManager) = False Then

Connectors = FamilyInstance1.MEPModel.ConnectorManager.Connectors.Cast(Of Connector).ToList

Connectors.RemoveAll(Function(X As Connector) X.IsConnected = True AndAlso X.Domain <> Domain.DomainElectrical)

If Connectors.Count > 0 Then

Connector = Connectors(0)

Exit For

End If

End If

End If

Next

If IsNothing(Connector) = False Then

Circuit = ElectricalSystem.Create(Connector, Connector.ElectricalSystemType)

'--

Parameters = Circuit.GetParameters("Numero do Circuito")

Parameter0 = Parameters(0)

Parameter0.SetValueString("1")

'--

Circuit.SelectPanel(Panel) '<<<ERROR

End If

Next

Transaction.Commit()

End Using

'Retorno
Return Result.Succeeded

End Function

0 Likes
Message 7 of 46

Anonymous
Not applicable

Good Morning.
I need to edit the voltage and number of poles.
Does anyone have code that works to help me?

 

My code:

 

Public Function Execute(commandData As ExternalCommandData, ByRef message As String, elements As ElementSet) As Result Implements IExternalCommand.Execute

Dim BuiltInCategorys As New List(Of BuiltInCategory)
Dim eKeyWorkReferences As eKeyWorkReferences
Dim ekeyworkreference As eKeyWorkReference
Dim Document As Document
Dim FamilyInstance0 As FamilyInstance = Nothing
Dim FamilyInstance1 As FamilyInstance = Nothing
Dim Parameters As List(Of Parameter)
Dim Parameter0 As Parameter
Dim Circuit As ElectricalSystem
Dim Panel As FamilyInstance
Dim Connectors As List(Of Connector)
Dim Connector As Connector = Nothing
Dim ElementSet As ElementSet

'Obtem o documento
Document = commandData.Application.ActiveUIDocument.Document

'Filtro
With BuiltInCategorys
.Add(BuiltInCategory.OST_ElectricalFixtures)
.Add(BuiltInCategory.OST_ElectricalEquipment)
.Add(BuiltInCategory.OST_LightingFixtures)
.Add(BuiltInCategory.OST_LightingDevices)
.Add(BuiltInCategory.OST_CommunicationDevices)
.Add(BuiltInCategory.OST_DataDevices)
.Add(BuiltInCategory.OST_FireAlarmDevices)
.Add(BuiltInCategory.OST_NurseCallDevices)
.Add(BuiltInCategory.OST_SecurityDevices)
.Add(BuiltInCategory.OST_TelephoneDevices)
'.Add(BuiltInCategory.OST_ConduitFitting)
'.Add(BuiltInCategory.OST_Conduit)
End With

'Solicita a seleção de elementos
eKeyWorkReferences = Engine.eRevitInterface.PickObjects(commandData, "Selecione os elementos",, BuiltInCategorys)


'Solicita a seleção do quadro
ekeyworkreference = Engine.eRevitInterface.PickObject(commandData, "Selecione o quadro",, BuiltInCategorys)


Panel = Document.GetElement(ekeyworkreference.Reference.ElementId)


Dim connectorSet As ConnectorSet = New ConnectorSet()

Dim csi As ConnectorSetIterator = Nothing

'Abre transação
Using Transaction As New eTransaction(Document)

Transaction.Start("Test", True)

For Each id As ElementId In eKeyWorkReferences.References.GetElementIds

FamilyInstance0 = Document.GetElement(id)

'--

Parameters = FamilyInstance0.GetParameters("Slot 1_Classificação de carga")

Parameter0 = Parameters(0)

Parameter0.SetValueString("Other")

'--

Parameters = FamilyInstance0.GetParameters("Slot 1_Fator de potência")

Parameter0 = Parameters(0)

Parameter0.SetValueString("0.85")

'--

Parameters = FamilyInstance0.GetParameters("Slot 1_Número de pólos")

Parameter0 = Parameters(0)

Parameter0.SetValueString("1")

'--

Parameters = FamilyInstance0.GetParameters("Slot 1_Potência ativa (W)")

Parameter0 = Parameters(0)

Parameter0.SetValueString("100")

'--

For Each ww As ElementId In FamilyInstance0.GetSubComponentIds

FamilyInstance1 = Document.GetElement(ww)

If IsNothing(FamilyInstance1.MEPModel) = False Then

If IsNothing(FamilyInstance1.MEPModel.ConnectorManager) = False Then

Connectors = FamilyInstance1.MEPModel.ConnectorManager.Connectors.Cast(Of Connector).ToList

Connectors.RemoveAll(Function(X As Connector) X.IsConnected = True AndAlso X.Domain <> Domain.DomainElectrical)

If Connectors.Count > 0 Then

Connector = Connectors(0)

Exit For

End If

End If

End If

Next

If IsNothing(Connector) = False Then

Circuit = ElectricalSystem.Create(Connector, Connector.ElectricalSystemType)

'--

Parameters = Circuit.GetParameters("Numero do Circuito")

Parameter0 = Parameters(0)

Parameter0.SetValueString("1")

'--

Circuit.SelectPanel(Panel) '<<<ERROR

End If

Next

Transaction.Commit()

End Using

'Retorno
Return Result.Succeeded

End Function

0 Likes
Message 8 of 46

Revitalizer
Advisor
Advisor

InsertCode.png




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 9 of 46

Anonymous
Not applicable

Good Morning.
I need to edit the voltage and number of poles.
Does anyone have code that works to help me?

 Public Function Execute(commandData As ExternalCommandData, ByRef message As String, elements As ElementSet) As Result Implements IExternalCommand.Execute

            Dim BuiltInCategorys As New List(Of BuiltInCategory)
            Dim eKeyWorkReferences As eKeyWorkReferences
            Dim ekeyworkreference As eKeyWorkReference
            Dim Document As Document
            Dim FamilyInstance0 As FamilyInstance = Nothing
            Dim FamilyInstance1 As FamilyInstance = Nothing
            Dim Parameters As List(Of Parameter)
            Dim Parameter0 As Parameter
            Dim Circuit As ElectricalSystem
            Dim Panel As FamilyInstance
            Dim Connectors As List(Of Connector)
            Dim Connector As Connector = Nothing
            'Dim ElementSet As ElementSet

            'Obtem o documento
            Document = commandData.Application.ActiveUIDocument.Document

            'Filtro
            With BuiltInCategorys
                .Add(BuiltInCategory.OST_ElectricalFixtures)
                .Add(BuiltInCategory.OST_ElectricalEquipment)
                .Add(BuiltInCategory.OST_LightingFixtures)
                .Add(BuiltInCategory.OST_LightingDevices)
                .Add(BuiltInCategory.OST_CommunicationDevices)
                .Add(BuiltInCategory.OST_DataDevices)
                .Add(BuiltInCategory.OST_FireAlarmDevices)
                .Add(BuiltInCategory.OST_NurseCallDevices)
                .Add(BuiltInCategory.OST_SecurityDevices)
                .Add(BuiltInCategory.OST_TelephoneDevices)
                '.Add(BuiltInCategory.OST_ConduitFitting)
                '.Add(BuiltInCategory.OST_Conduit)
            End With

            'Solicita a seleção de elementos
            eKeyWorkReferences = Engine.eRevitInterface.PickObjects(commandData, "Selecione os elementos",, BuiltInCategorys)


            'Solicita a seleção do quadro
            ekeyworkreference = Engine.eRevitInterface.PickObject(commandData, "Selecione o quadro",, BuiltInCategorys)


            Panel = Document.GetElement(ekeyworkreference.Reference.ElementId)


            Dim connectorSet As ConnectorSet = New ConnectorSet()

            Dim csi As ConnectorSetIterator = Nothing

            'Abre transação
            Using Transaction As New eTransaction(Document)

                Transaction.Start("Test", True)

                For Each id As ElementId In eKeyWorkReferences.References.GetElementIds

                    FamilyInstance0 = Document.GetElement(id)

                    '--

                    Parameters = FamilyInstance0.GetParameters("Slot 1_Classificação de carga")

                    Parameter0 = Parameters(0)

                    Parameter0.SetValueString("Other")

                    '--

                    Parameters = FamilyInstance0.GetParameters("Slot 1_Fator de potência")

                    Parameter0 = Parameters(0)

                    Parameter0.SetValueString("0.85")

                    '--

                    Parameters = FamilyInstance0.GetParameters("Slot 1_Número de pólos")

                    Parameter0 = Parameters(0)

                    Parameter0.SetValueString("1")

                    '--

                    Parameters = FamilyInstance0.GetParameters("Slot 1_Potência ativa (W)")

                    Parameter0 = Parameters(0)

                    Parameter0.SetValueString("100")

                    '--

                    For Each ww As ElementId In FamilyInstance0.GetSubComponentIds

                        FamilyInstance1 = Document.GetElement(ww)

                        If IsNothing(FamilyInstance1.MEPModel) = False Then

                            If IsNothing(FamilyInstance1.MEPModel.ConnectorManager) = False Then

                                Connectors = FamilyInstance1.MEPModel.ConnectorManager.Connectors.Cast(Of Connector).ToList

                                Connectors.RemoveAll(Function(X As Connector) X.IsConnected = True AndAlso X.Domain <> Domain.DomainElectrical)

                                If Connectors.Count > 0 Then

                                    Connector = Connectors(0)

                                    Exit For

                                End If

                            End If

                        End If

                    Next

                    If IsNothing(Connector) = False Then

                        Circuit = ElectricalSystem.Create(Connector, Connector.ElectricalSystemType)

                        '--

                        Parameters = Circuit.GetParameters("Numero do Circuito")

                        Parameter0 = Parameters(0)

                        Parameter0.SetValueString("1")

                        '--

                        Circuit.SelectPanel(Panel)   '<<<ERROR

                    End If

                Next

                Transaction.Commit()

            End Using

            'Retorno
            Return Result.Succeeded

        End Function
0 Likes
Message 10 of 46

crapai
Advocate
Advocate

Any updates on whether voltage and number of poles can be set with the API yet?

0 Likes
Message 11 of 46

ricaun
Advisor
Advisor

The last time I tried this problem Instance Voltage problem.

 

I tried this approach.

 

Approach 1:
* Create a family with a type fix voltage
* Create an electrical system with the instance voltage family with this temporary family
* Connect the some Panel
* Delete the temporary family

 

This first approach works but if you disconnect the panel Revit loses the Voltage reference and goes to zero.

 

Approach 2:
* Create a Voltage global parameter
* Set all the instance voltage references to the Voltage global parameter
* Create an electrical system
* Connect the some Panel
* Delete the Voltage global parameter

 

Like the first approach if you disconnect the panel Revit loses the Voltage reference and goes to zero. You could not delete the Voltage global parameter and Revit does not lose the Voltage reference.

 

I tested on Revit 2022 and this bug still haunts the family with the instance Voltage parameter.

 

See yaa!

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 12 of 46

jeremy_tammik
Alumni
Alumni

Sorry to hear this problem persists. I asked the development team for you and will let you know what they suggest.

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 13 of 46

ricaun
Advisor
Advisor

I believe is a bug, I tested without using the API and have the same problem...

 

I create 2 families, one with Voltage reference on the Instance and another on the Type.

 

If I create an electrical system selecting these 2 instances works great, but if I delete the instance with the Type Voltage reference and disconnect the panel.

 

Voltage goes to Zero for some Revit reasons...

 

 

See Yaa!

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 14 of 46

jeremy_tammik
Alumni
Alumni

The development team replied:

 

I see two issues in that thread:

 

#1: The problem where voltage on circuit is set to 0 when removing a connected element:

  

https://youtu.be/yOI1kOlB0oc

  

#2: Possibly a gap in what is possible in the API vs. the UI; if a circuit is created with connectors that have their connection characteristics (voltage and poles (V&P) as instance parameters, the user is prompted in the UI to specify the V&P. However, the create system API appears to not have such method. We will need to confirm to make sure.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 15 of 46

crapai
Advocate
Advocate

I hope something can be done with the API, to either let the current instant values be used or to allow us to input values for poles and voltage when we make a circuit. We have a job with over 1200 process equipment connections where we have electrical information from the owner. We would like to create circuits for these using that information. Other wise it is very time consuming the manually enter that information when creating power circuits for that many connectors.

 

It's worth noting that while the voltage gets overriden to 0, this doesn't happen to the number of poles. It will use whatever value the instance paramter associated with the connector had when the API command is used. If this worked the same way for voltage I feel like it would help a lot of people.

0 Likes
Message 16 of 46

crapai
Advocate
Advocate

Any updates on this? Has the team looked into this?

0 Likes
Message 17 of 46

jeremy_tammik
Alumni
Alumni

Yes. Logged as issue REVIT-180706 [API ElectricalSystem.Create() cannot specify voltage and poles].

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 18 of 46

bxw
Enthusiast
Enthusiast

Glad to see some movement on this, I've been mostly using Type parameters to avoid this issue.  It would be awesome to have this fixed.  

0 Likes
Message 19 of 46

jeremy_tammik
Alumni
Alumni

Keeping fingers crossed a fix makes it into release asap.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 20 of 46

crapai
Advocate
Advocate

Do we know what kind of release would contain this? Hotfix? Update? Yearly release?