Hi,

I want code snippet to create polygon in Processbook. Not finding much info in VBA help file.

Below is the sample input.

TOP | LEFT | points | fillcolor | strokecolor | Z-INDEX |

278px | 314px | 0,0,0,22,14,11,0,0 | black | black | 54 |

Hi,

I want code snippet to create polygon in Processbook. Not finding much info in VBA help file.

Below is the sample input.

TOP | LEFT | points | fillcolor | strokecolor | Z-INDEX |

278px | 314px | 0,0,0,22,14,11,0,0 | black | black | 54 |

Hi Doddabasappa ,

Try the below code snippet.

Sub createPolygon() Dim polySym As PBSymLib.Polygon Set polySym = ThisDisplay.Symbols.Add(pbSymbolPolygon) polySym.Endpoints.Insert 1, 0, 0 polySym.Endpoints.Insert 2, 0, 22 polySym.Endpoints.Insert 3, 14, 11 polySym.Endpoints.Insert 4, 0, 0 polySym.Endpoints.Remove (5) polySym.Endpoints.Remove (5) polySym.Endpoints.Remove (5) polySym.Endpoints.Remove (5) polySym.Endpoints.Remove (5) polySym.FillColor = vbBlack polySym.LineColor = vbBlack polySym.Top = 278 polySym.Left = 314 End Sub

Regards,

Akash

Hi,

Can you some explain on polySym.Endpoints.Remove (5)? I want to know on what basis we decide which endpoint needs to be removed.

I will be having point different number of points for polygon (ex: 10, 18, 26 etc). Sometime I get error saying "Number submitted was outside range".

HI Doddabsappa,

When we add a polygon using VBA in Processbook, It creates a default polygon with 5 endpoints.

In your case you need a polygon have 4 endpoints and hence we wrote

polySym.Endpoints.Insert 1, 0, 0

polySym.Endpoints.Insert 2, 0, 22

polySym.Endpoints.Insert 3, 14, 11

polySym.Endpoints.Insert 4, 0, 0

When these 4 points were added the existing 5 default endpoints created had to be deleted , and since you had 4 endpoints to add, the unnecessary endpoint start from 5 (no. of endpoints added + 1 ie 4+1 =5) and hence below code

polySym.Endpoints.Remove (5)

polySym.Endpoints.Remove (5)

polySym.Endpoints.Remove (5)

polySym.Endpoints.Remove (5)

polySym.Endpoints.Remove (5)

Now suppose you need to add a polygon with 10 endpoint you would add the above remove statement 5 times having index 11 (10 +1).

polySym.Endpoints.Remove (11)

Hope that explained your query.

Regards,

Akash

Hi Doddabasappa ,

Try the below code snippet.

Regards,

Akash