Nevron Forum

Creating Multiple Ports Evenly Spacing

https://www.nevron.com/Forum/Topic6991.aspx

By Volvick Derose 1 - Thursday, September 27, 2012

If you have some sample code that can help me with this process, can you please post it. I try to create a shape with multiple ports to the left and multiple ports to the right. I don't have any problem doing that as you can see. The problem I have if if the number of ports to the left and right are not equal. Users will need to specify the number of port to the right or left.

for instance if right = 4 and left = 4, no problem, but if right is 4 and left is 2, the 2 ports to the left are not spacing center (or even space) to the shape

see the picture for instance one of them is good, but in the next 2, the ports are not centered or align properly.

You may have already done something like that, so provide a sample code will be nice
By Nevron Support - Monday, October 1, 2012

The NRotatedBoundsPort is always anchored to a location, that is relative to the actual shape bounds. This location is specified with X and Y factors of the actual shape bounds. So if you have N ports to place on a shape side, you need to create the ports with step 100 / N+1. (50, 50) is the center of the shape, so the formula for the left side ports is: X=-50, Y=-50 + (I * (100 / N+1)), where N is the number of ports to evenly space on the side and I is the 1 based index of the port to place. If you have two ports their Y percent factors become:

1. -50 + (1 * (100 / (2+1)) = -50 + 33;
1. -50 + (2 * (100 / (2+1)) = -50 + 66;