
Re: VBA:Polygon Creation
aksnk89 Jul 28, 2016 7:15 AM (in response to Doddabasappa)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

Re: VBA:Polygon Creation
Doddabasappa Aug 1, 2016 10:20 AM (in response to Doddabasappa)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".

Re: VBA:Polygon Creation
aksnk89 Aug 1, 2016 10:53 AM (in response to Doddabasappa)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
