Table of Contents

Class Wire

Namespace
OpenMEPRevit.Element
Assembly
OpenMEPRevit.dll

Electrical wire element.

public class Wire
Inheritance
Wire
Inherited Members

Methods

AppendVertex(Element, Point)

Appends one vertex to the end of the wire.

public static Element AppendVertex(Element wire, Point vertexPoint)

Parameters

wire Element

the wire

vertexPoint Point

The vertex to be appended.

Returns

Element

wire

Exceptions

ArgumentException

The vertex point cannot be added to the wire because there is already a vertex at this position on the view plane (within tolerance).

ArgumentNullException

A non-optional argument was null

DisabledDisciplineException

None of the following disciplines is enabled: Mechanical Electrical Piping.

InvalidOperationException

The end point is already connected to an element, so a new endpoint vertex cannot be appended.

AreVertexPointsValid(List<Point>, Connector, Connector)

Checks if the given vertex points are valid for the wire.

[NodeCategory("Query")]
public static bool AreVertexPointsValid(List<Point> vertexPoints, Connector startConnector, Connector endConnector)

Parameters

vertexPoints List<Point>

The vertex points.

startConnector Connector

The start connector of the wire.

endConnector Connector

The end connector of the wire.

Returns

bool

True if the given vertex points are valid, false otherwise.

Remarks

X and Y values are compared of the vertices.

Exceptions

ArgumentNullException

A non-optional argument was null

ConnectTo(Element, Connector, Connector)

Connects the wire to other elements.

public static void ConnectTo(Element wire, Connector startConnectorTo, Connector endConnectorTo)

Parameters

wire Element

the wire

startConnectorTo Connector

The connector that the start connector of the wire connects to.

endConnectorTo Connector

The connector that the end connector of the wire connects to.

Exceptions

ArgumentException

startConnectorTo cannot be connected to a wire, as it is not an electrical connector. -or- endConnectorTo cannot be connected to a wire, as it is not an electrical connector. -or- startConnectorTo or/and endConnectorTo cannot be connected to a wire, as wire can't connect both connectors to same wire or same connector.

InvalidOperationException

Cannot connect the wire to the start connector or the end connector.

GetMEPSystems(Element)

Gets the systems to which the wire belongs.

public static IEnumerable<Element?> GetMEPSystems(Element wire)

Parameters

wire Element

Returns

IEnumerable<Element>

The systems to which the wire belongs.

Remarks

One wire might belong to more than one circuit.

GetVertex(Element, double)

Gets the position of an existing vertex.

public static Point? GetVertex(Element wire, double index)

Parameters

wire Element

the wire

index double

The index of the existing vertex. Should be between 0 and Autodesk.Revit.DB.Electrical.Wire.NumberOfVertices.

Returns

Point

The position of the vertex. It is the offset point for the start and end vertex, not the connector point. If the wire connects to one device, it may have offset; otherwise, the start and end vertex is same as the connector point.

Exceptions

ArgumentException

The index should be between 0 and the number of vertices of the wire.

DisabledDisciplineException

None of the following disciplines is enabled: Mechanical Electrical Piping.

GroundConductorNumber(Element)

The ground conductor number. Its default value is zero after created.

[NodeCategory("Query")]
public static double GroundConductorNumber(Element wire)

Parameters

wire Element

the wire

Returns

double

ground conductor number

HotConductorNum(Element)

The hot conductor number. Its default value is zero after created.

[NodeCategory("Query")]
public static double HotConductorNum(Element wire)

Parameters

wire Element

Returns

double

hot conduct number

InsertVertex(Element, double, Point)

Inserts a new vertex before the specified index.

[NodeCategory("Actions")]
public static Point? InsertVertex(Element wire, double index, Point vertexPoint)

Parameters

wire Element

the wire

index double

The index of the vertex to come after this new vertex. Should be between 0 and Autodesk.Revit.DB.Electrical.Wire.NumberOfVertices.

vertexPoint Point

The point of the new vertex.

Returns

Point

Remarks

To add a new vertex to the end of the wire, use Autodesk.Revit.DB.Electrical.Wire.AppendVertex(Autodesk.Revit.DB.XYZ).

Exceptions

ArgumentException

The index should be between 0 and the number of vertices of the wire. -or- The vertex point cannot be added to the wire because there is already a vertex at this position on the view plane (within tolerance).

ArgumentNullException

A non-optional argument was null

DisabledDisciplineException

None of the following disciplines is enabled: Mechanical Electrical Piping.

InvalidOperationException

Can't insert the vertex before the start vertex if the start point connects to one element.

IsVertexPointValid(Element, Point)

Checks if the given vertex point can be added to this wire.

[NodeCategory("Query")]
public static bool IsVertexPointValid(Element wire, Point vertexPoint)

Parameters

wire Element

the wire

vertexPoint Point

The vertex point.

Returns

bool

True if the vertex point can be added, false if the point cannot be added because there is already a vertex at this position on the view plane (within tolerance).

Remarks

Vertices are projected to the view plane for comparison.

Exceptions

ArgumentNullException

A non-optional argument was null

NeutralConductorNum(Element)

The neutral conductor number. Its default value is zero after created.

[NodeCategory("Query")]
public static double NeutralConductorNum(Element wire)

Parameters

wire Element

Returns

double

neutral conductor number

RemoveVertex(Element, double)

Removes the vertex corresponding to the specified index. Can not remove the start or end vertex if it already connects to other element.

[NodeCategory("Actions")]
public static void RemoveVertex(Element wire, double index)

Parameters

wire Element

the wire

index double

The index which should be in [0, NumberOfVertices).

Exceptions

ArgumentException

The index should be between 0 and the number of vertices of the wire.

DisabledDisciplineException

None of the following disciplines is enabled: Mechanical Electrical Piping.

InvalidOperationException

The wire has only 2 vertices, so one cannot be removed. -or- Can't remove the vertex when the vertex is start or end point and the wire connects to one element.

SetVertex(Element, double, Point)

Sets the position of a given vertex. If the vertex is start or end point, and the wire connects to electrical device, the wire end offset will be set according to the given vertex. If the vertex is start or end point, and the wire connects to other wire, user can't set the vertex and exception will be thrown. If the vertex is start or end point, and the wire connects to nothing, the vertex will be set as the given vertex.

[NodeCategory("Actions")]
public static void SetVertex(Element wire, double index, Point vertexPoint)

Parameters

wire Element

the wire

index double

The index of the existing vertex. Should be between 0 and Autodesk.Revit.DB.Electrical.Wire.NumberOfVertices.

vertexPoint Point

The new position for the vertex.

Exceptions

ArgumentException

The index should be between 0 and the number of vertices of the wire. -or- The vertex point cannot be added to the wire because there is already a vertex at this position on the view plane (within tolerance).

ArgumentNullException

A non-optional argument was null

DisabledDisciplineException

None of the following disciplines is enabled: Mechanical Electrical Piping.

InvalidOperationException

Can't set the vertex when the vertex is start or end point and the wire connects to other wire.

WiringType(Element)

The wiring type(arc or chamfer) for the wire.

[NodeCategory("Query")]
public static string? WiringType(Element wire)

Parameters

wire Element

Returns

string

wiring type of wire

Remarks

If the WiringType is arc, the shape of the wire depends on the number of points - it may be linear, a circular arc, or a spline.

Exceptions

ArgumentOutOfRangeException

When setting this property: A value passed for an enumeration argument is not a member of that enumeration