## ConnectNewPolygonToEdge

### Introduced

v1.5

### Description

Adds an edge to the polygon being created and shares it with an existing edge

### Scripting Syntax

    oLong = ConnectNewPolygonToEdge( InputObj, EdgeID, [InsertPosition], [InvertPolygon] );

### Return Value

Returns the ID of the polygon affected as a Long (-1 is returned if polygon has less than 3 points)

### Parameters

Parameter | Type | Description
--- | --- | ---
InputObj | String | Mesh holding the polygon being built
EdgeID | Integer | ID of the target edge to connect with
Possible Values: | Description:
0<=i | index of the edge in the mesh
InsertPosition | Long | Ordinal of the vertex where to insert the new edge in the polygon Default Value: 0
Possible Values: | Description:
0 | The edge is added at the end of the list
0 | The edge is inserted between vertices i-1 and i
InvertPolygon | Boolean | true if the adjacent polygon should be inverted before accomodating a CW-CCW connection

### Examples

#### VBScript Example

    'This example shows how to add a polygon to an existing mesh
    newscene
    ' Add a quad to a grid and connect one of its edges to an existing edge
    dim obj, poly
    set obj = CreatePrim( "Grid", "MeshSurface" )
    SelectObj obj
    ApplyOp "CreatePolygon", obj, siUnspecified
    AddPointToNewPolygon obj, -6.088, 0.0, 0.864
    AddPointToNewPolygon obj, -6.345, 0.0, 2.953
    poly = ConnectNewPolygonToEdge( obj, 16, 0 )
    SelectObj obj & ".poly[" & poly & "]"
    ' Create a disc and fill the hole in the center
    set obj = CreatePrim( "Disc", "MeshSurface" )
    SelectObj obj
    ApplyOp "CreatePolygon", obj, siUnspecified
    ConnectNewPolygonToEdge obj, 128
    ConnectNewPolygonToEdge obj, 27
    ConnectNewPolygonToEdge obj, 61
    poly = ConnectNewPolygonToEdge( obj, 95 )
    SelectObj obj & ".poly[" & poly & "]"

### See Also

ApplyOp AddPointToNewPolygon ConnectNewPolygonToPoint