OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   VBA Nodes Tutorial (http://forum.oberonplace.com/showthread.php?t=6046)

 Sablesword 21-09-2008 13:32

VBA Nodes Tutorial

Is there a good tutorial anywhere for working with nodes in Coreldraw VBA?

The "record a macro" trick gives me a good starting point for many uses of VBA, but not for creating, deleting, & otherwise manipulating nodes.

 shelbym 23-09-2008 22:01

The best information you will find about nodes is in the help file. There are several examples for what you want....

Adding a node to a SubPath
Code:

``` Dim sp As SubPath  For Each sp In ActiveShape.Curve.Subpaths   sp.AddNodeAt 0.5, cdrRelativeSegmentOffset  Next sp```
Adding a node to a Segment
Code:

```Dim s As Shape  Set s = ActiveLayer.CreateCurveSegment(2, 8.3, 5.3, 8.5, 1.5, -62, 2.4, 84)  s.Curve.Segments(1).AddNodeAt 0.5, cdrRelativeSegmentOffset```
Delete a Node
Code:

``` Dim s As Shape  Dim n As Node  Dim i As Long, Num As Long  Set s = ActiveShape  If s.Type <> cdrCurveShape Then Exit Sub  Num = s.Curve.Nodes.Count  i = 1  While i <= Num   Set n = s.Curve.Nodes(i)   If n.Type = cdrCuspNode Then   If n.SubPath.Nodes.Count = 2 Then     ' Deleting a node from a segment containing only 2 nodes     ' will remove the whole segment. If we are deleting the last     ' node of the subpath, then we must move one more step back.     If n.SubPath.EndNode Is n Then i = i - 1     n.Delete     Num = Num - 2     i = i - 1   Else     ' Just delete the node and adjust the number of nodes left.     n.Delete     Num = Num - 1     i = i - 1   End If   End If   i = i + 1  Wend```
There are many many more examples that should help you out in the help file!

-Shelby

 All times are GMT -5. The time now is 06:50.