Product : Engine, Version : 5.1.1.1038, ArticleID : 41024138

HowTo : How to make an offset of an SPLine

Article41024138
TypeHowTo
ProductEngine
Version5.1.1.1038
Date Added10/27/2005
Submitted byPierpaolo Dondio
Keywords

Subject

How to make an offset of an SPLine

Summary

In our application, we should draw the internal outline of some shape, i.e., given for example a closed spline, we should draw an internal closed spline that follows the external spliena t a fixed distance, like 1 cm for example.
Is it possible to do that ?

Solution

It is possible to do this action when you follow the following procedure:

1. Make an SPline
2. Ensure that the SPline is closed by setting the Flag property to PlFlagCLOSE.
3. Set the SPline to a simple polyline by setting the SPlineFlag property to SFlagSTANDARD.
4. Use the CmdOffset function to create the 2nd polyline
5. Set the polylines to SPline by setting the SPlineFlag property to this value they had before you set it to SFlagSTANDARD. These values are (SFlagCONTROLPOINTS, SFlagFITTING, SFlagQUADRATIC)

Regarding this procedure, you can use the following code in Visual Basic 6.0:
Dim Pline As vdPolyline
Dim temPLine As vdPolyline
Dim newPoly As vdPolyline

VDPro1.CommandAction.Zoom "W", Array(-5, -5), Array(10, 10)

Set Pline = VDPro1.ActiveDocument.Entities.AddPolyLine(Array(Array(-2, 0, 0), Array(3, 0, 0), Array(3, 2, 0), Array(5, 6, 0), Array(-3, 3, 0)))
Pline.Flag = PlFlagCLOSE 'Ensure that is closed
Pline.SPlineFlag = SFlagFITTING 'Make the SPline
Pline.Invalidate

Set temPLine = VDPro1.CreateInstance(OBJ_POLYLINE) 'Create a copy of the spline above as a simple polyline
Set temPLine = Pline.Copy
temPLine.SPlineFlag = SFlagSTANDARD

MsgBox "Press ok to create a offset image of the object"
VDPro1.CommandAction.CmdOffset temPLine, 0.8, Array(4, 1) 'Offset the temporary polyline

Set newPoly = VDPro1.ActiveDocument.Entities.Last 'Set the newpoly to be the result of cmdoffset
newPoly.SPlineFlag = SFlagFITTING
VDPro1.DrawEntity newPoly, 1