Trying to create an electrical system

Trying to create an electrical system

Anonymous
Not applicable
2,158 Views
2 Replies
Message 1 of 3

Trying to create an electrical system

Anonymous
Not applicable

Hello everybody,

I am here maybe with a stupid question,

 

I am trying to create an electrical circuit via the revit API. I have see that there are not many examples on how to do it.

I have seen in the revit API help the referece to the "NewElectricalSystem" Method (http://revitapisearch.com/html/654da57c-4209-f64d-5f4f-8635c4708f98.htm) and I am trying to do it with the next code:

     FamilyInstance eLoad = doc.GetElement(subCompId) as FamilyInstance;
    ConnectorSet cS = eLoad.MEPModel.ConnectorManager.Connectors;
    foreach(Connector c in cS)
    {
        ElectricalSystem nES = Autodesk.Revit.Creation.Document.NewElectricalSystem(c,ElectricalSystemType.PowerCircuit);
    }
}

It seems easy, but unfortunately y get the next error:

An object reference is required for the non-static field, method, or property 'Autodesk.Revit.Creation.Document.NewElectricalSystem(Autodesk.Revit.DB.Connector, Autodesk.Revit.DB.Electrical.ElectricalSystemType)' (CS0120) 

And I have no idea on how do i have to proceed in order to fix it.

Can anyone give any help??

 

 

many tanks in advance!

0 Likes
Accepted solutions (1)
2,159 Views
2 Replies
Replies (2)
Message 2 of 3

JimJia
Alumni
Alumni
Accepted solution
hi,
Please replace Autodesk.Revit.Creation.Document.NewElectricalSystem with doc.Create.NewElectricalSystem.

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes
Message 3 of 3

Anonymous
Not applicable

Perfect!!

Thanks a lot!

0 Likes