Object Model Reference : Classes : S : SubPath : Methods : SubPath.GetIntersections |
Function GetIntersections(Target As SubPath, [OffsetType As cdrSegmentOffsetType = cdrRelativeSegmentOffset]) As CrossPoints
Member of SubPath
The GetIntersections method finds all the points of intersection for two subpaths.
Parameter
|
Description
|
Target
|
Specifies the subpath with which to intersect
|
OffsetType
|
Specifies the offset type of the intersection point, and returns cdrSegmentOffsetType. This parameter is optional, and its default value is cdrRelativeSegmentOffset (1).
|
The following VBA example displays the number of times the two selected curves intersect and marks each intersection point with a small circle.
Sub Test() |
Dim sr As ShapeRange |
Dim sp1 As SubPath, sp2 As SubPath |
Dim cps As CrossPoints, cp As CrossPoint |
Dim x As Double, y As Double, n As Long |
Set sr = ActiveSelectionRange |
If sr.Count <> 2 Then |
MsgBox "Please select two curves", vbCritical |
Exit Sub |
End If |
If sr(1).Type <> cdrCurveShape Or sr(2).Type <> cdrCurveShape Then |
MsgBox "One of the selected shapes is not a curve", vbCritical |
Exit Sub |
End If |
n = 0 |
For Each sp1 In sr(1).Curve.Subpaths |
For Each sp2 In sr(2).Curve.Subpaths |
Set cps = sp1.GetIntersections(sp2) |
For Each cp In cps |
ActiveLayer.CreateEllipse2 cp.PositionX, cp.PositionY, 0.05 |
Next cp |
n = n + cps.Count |
Next sp2 |
Next sp1 |
MsgBox n & " intersection point(s) found" |
End Sub |
Copyright 2013 Corel Corporation. All rights reserved.