Previous Document Next Document

Object Model Reference : Classes : S : Segment : Methods : Segment.FindParamOffset


Segment.FindParamOffset

Function FindParamOffset(AbsoluteOffset As Double, ParamOffset As Double, [Remainder As Double]) As Boolean

Description

Member of Segment

The FindParamOffset method returns the parametric offset for a specified absolute offset.

If the segment is shorter than the specified offset, the function returns False, and the remainder of the offset is returned in the Remainder parameter. Otherwise, the function returns True, and the ParamOffset parameter returns the parametric offset for the segment.

Parameter
Description
AbsoluteOffset
Specifies the absolute offset value
ParamOffset
Specifies the value of the parametric offset
Remainder
Specifies the remainder. This parameter is optional, and its default value is 0.

VBA example

The following VBA example duplicates a shape and distributes it along a path. The shape and the path must be selected, and the path must be selected last.

Sub Test()
 Dim sr As ShapeRange
 Dim sPath As Shape, sShape As Shape, sWork As Shape
 Dim dWidth As Double, Offset As Double, Rest As Double, t As Double
 Dim x As Double, y As Double, a As Double, sx As Double, sy As Double
 Dim seg As Segment
 Set sr = ActiveSelectionRange
 If sr.Count <> 2 Then
  MsgBox "Please select two shapes", vbCritical
  Exit Sub
 End If
 If sr(1).Type <> cdrCurveShape Then
  MsgBox "Last selected shape must be a curve", vbCritical
  Exit Sub
 End If
 Set sPath = sr(1)
 Set sShape = sr(2)
 ActiveDocument.ReferencePoint = cdrCenter
 dWidth = sShape.SizeWidth
 sShape.GetPosition sx, sy
 Offset = dWidth / 2
 For Each seg In sPath.Curve.Segments
  While seg.FindParamOffset(Offset, t, Rest)
   seg.GetPointPositionAt x, y, t, cdrParamSegmentOffset
   a = seg.GetTangentAt(t, cdrParamSegmentOffset)
   Set sWork = sShape.Duplicate(x - sx, y - sy)
   sWork.Rotate a
   Offset = Offset + dWidth
  Wend
  Offset = Rest
 Next seg
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.