Object Model Reference : Classes : S : Segment : Methods : Segment.GetIntersections |
Function GetIntersections(Target As Segment, [OffsetType As cdrSegmentOffsetType = cdrParamSegmentOffset]) As CrossPoints
Member of Segment
The GetIntersections method finds all points of intersection between two segments.
Parameter
|
Description
|
Target
|
Specifies the second object
|
OffsetType
|
Specifies the type of offset of the point on the curves subpath, and returns cdrSegmentOffsetType. This parameter is optional, and its default value is cdrParamSegmentOffset (2).
|
The following VBA example displays the number of times the first segment of the first two subpaths of the selected curve intersect, and it marks each intersection point with a small circle.
Sub Test() |
Dim seg1 As Segment, seg2 As Segment |
Dim cps As CrossPoints, cp As CrossPoint |
Dim x As Double, y As Double |
If ActiveShape Is Nothing Then |
MsgBox "Nothing selected", vbCritical |
Exit Sub |
End If |
If ActiveShape.Type <> cdrCurveShape Then |
MsgBox "Select a curve", vbCritical |
Exit Sub |
End If |
If ActiveShape.Curve.Subpaths.Count < 2 Then |
MsgBox "The curve must have 2 subpaths", vbCritical |
Exit Sub |
End If |
Set seg1 = ActiveShape.Curve.Subpaths(1).Segments(1) |
Set seg2 = ActiveShape.Curve.Subpaths(2).Segments(1) |
Set cps = seg1.GetIntersections(seg2) |
For Each cp In cps |
ActiveLayer.CreateEllipse2 cp.PositionX, cp.PositionY, 0.05 |
Next cp |
MsgBox cps.Count & " intersection point(s) found" |
End Sub |
Copyright 2013 Corel Corporation. All rights reserved.