Previous Document Next Document

Object Model Reference : Classes : N : Node : Methods : Node.ConnectWith


Node.ConnectWith

Sub ConnectWith(Target As Node)

Description

Member of Node

The ConnectWith method connects two ending nodes by drawing a straight line between them.

 
The JoinWith method connects two ending nodes by merging them into one.

Parameter
Description
Target
Specifies the node to join to the current node

VBA example

The following VBA example connects the ending node of each open subpath with the starting node of the next open subpath.

Sub Test()
 Dim s As Shape
 Dim spath As SubPath
 Dim n1 As Node, n2 As Node
 Dim Joined As Boolean, Repeat As Boolean
 Set s = ActiveShape
 If s.Type <> cdrCurveShape Then s.ConvertToCurves
 Repeat = True
 While Repeat
  Set n1 = Nothing
  Set n2 = Nothing
  Joined = False
  For Each spath In s.Curve.Subpaths
   If Not spath.Closed Then
    If n2 Is Nothing Then
     ' The first open SubPath found
     Set n1 = spath.StartNode
     Set n2 = spath.EndNode
    Else
     ' n2 is the last node of previous open SubPath
     ' Join it with the first node of the current subpath
     n2.ConnectWith spath.StartNode
     ' Joining subpaths reduces the number of subpath in the curve
     ' So we need to restart
     Joined = True
     Exit For
    End If
   End If
  Next spath
  If Not Joined Then
   If Not n1 Is Nothing Then
    ' There's only one open subpath left. Close it
    n1.ConnectWith n2
   End If
   Repeat = False
  End If
 Wend
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.