0

I'm new here and am also relatively new to VBA. I've been struggling with this problem for a while and can't seem to find a solution. I have points that correspond to either endpoint of a wall or intersections of a wall (Shown in an attached image).

Points

enter code here

I need to turn this information into points along the wall boundary (from a given wall thickness) sorted in a clockwise manner from an arbitrary point. See the attached image.

Goal

I've managed to create points at boundaries (very roughly) by shrinking back each node by half of the wall thickness and then moving each resulting node "side to side" in the perpendicular direction by half of the wall thickness.

The data I have does show node pairs for each line. These "AtoB" line type connection pairs exist node to node and don't overlap of the cross.
Any suggestions or help would be greatly appreciated. I'm a bit stuck. Thanks! J

Below is output information for an "L" shaped wall: enter image description here

I then take the XY coordinates and shift them:

ReDim CoordsArr(9, 3) '10 Walls total available per pier

''' Store coord in variables '''
For coordrow = 0 To Counter - 2
CoordsArr(coordrow, 0) = Cells(24 + coordrow, 5)
CoordsArr(coordrow, 1) = Cells(24 + coordrow, 6)
CoordsArr(coordrow, 2) = Cells(24 + coordrow, 8)
CoordsArr(coordrow, 3) = Cells(24 + coordrow, 9)
Next coordrow
''' Generate New Corner Points '''
ReDim POINTS_XY(19, 7) 'Array as (x1,y1,x2,y2,x3,y3,x4,y4) for points 
'above and below CL
For coordrow = 0 To Counter - 2
If Abs(CoordsArr(coordrow, 3) - CoordsArr(coordrow, 1)) = 0 Then
If CoordsArr(coordrow, 0) < CoordsArr(coordrow, 2) Then
XnewL = CoordsArr(coordrow, 0) + thick / 2
XnewR = CoordsArr(coordrow, 2) - thick / 2
POINTS_XY(coordrow, 0) = XnewL
POINTS_XY(coordrow, 1) = thick / 2
POINTS_XY(coordrow, 2) = XnewL
POINTS_XY(coordrow, 3) = -thick / 2
POINTS_XY(coordrow, 4) = XnewR
POINTS_XY(coordrow, 5) = thick / 2
POINTS_XY(coordrow, 6) = XnewR
POINTS_XY(coordrow, 7) = -thick / 2
ElseIf CoordsArr(coordrow, 0) > CoordsArr(coordrow, 2) Then
XnewL = CoordsArr(coordrow, 0) - thick / 2
XnewR = CoordsArr(coordrow, 2) + thick / 2
POINTS_XY(coordrow, 0) = XnewL
POINTS_XY(coordrow, 1) = thick / 2
POINTS_XY(coordrow, 2) = XnewL
POINTS_XY(coordrow, 3) = -thick / 2
POINTS_XY(coordrow, 4) = XnewR
POINTS_XY(coordrow, 5) = thick / 2
POINTS_XY(coordrow, 6) = XnewR
POINTS_XY(coordrow, 7) = -thick / 2
End If
ElseIf Abs(CoordsArr(coordrow, 2) - CoordsArr(coordrow, 0)) = 0 Then
If CoordsArr(coordrow, 1) < CoordsArr(coordrow, 3) Then
YnewD = CoordsArr(coordrow, 1) + thick / 2
YnewU = CoordsArr(coordrow, 3) - thick / 2
POINTS_XY(coordrow, 0) = -thick / 2
POINTS_XY(coordrow, 1) = YnewD
POINTS_XY(coordrow, 2) = thick / 2
POINTS_XY(coordrow, 3) = YnewD
POINTS_XY(coordrow, 4) = -thick / 2
POINTS_XY(coordrow, 5) = YnewU
POINTS_XY(coordrow, 6) = thick / 2
POINTS_XY(coordrow, 7) = YnewU
ElseIf CoordsArr(coordrow, 1) > CoordsArr(coordrow, 3) Then
YnewD = CoordsArr(coordrow, 1) - thick / 2
YnewU = CoordsArr(coordrow, 3) + thick / 2
POINTS_XY(coordrow, 0) = -thick / 2
POINTS_XY(coordrow, 1) = YnewD
POINTS_XY(coordrow, 2) = thick / 2
POINTS_XY(coordrow, 3) = YnewD
POINTS_XY(coordrow, 4) = -thick / 2
POINTS_XY(coordrow, 5) = YnewU
POINTS_XY(coordrow, 6) = thick / 2
POINTS_XY(coordrow, 7) = YnewU
End If
End If
Next coordrow
J.Parker
  • 21
  • 2
  • 1
    Please show some actual data and code, rather than an image and a vague allusion to something that you managed to do. That would focus the question in a way that would make it easier for others to help you. – John Coleman Mar 05 '19 at 10:45
  • My apologies. Thanks for the tip. I hope what I've provided helps make this more clear. – J.Parker Mar 05 '19 at 17:25
  • Thanks. Much better question now, though still a bit puzzling as to what is the form of the input and what the intended output is. – John Coleman Mar 05 '19 at 17:30
  • Got it. The input is just points that define start and end points of lines that together make the shape of a wall (blue dots in my first image). The intended output is the white dots in my second image. These white dots define the perimeter of the wall in two dimensions and need to be sorted in a clockwise manner around the wall perimeter. Does that help? The thickness of the wall defines these white dots. – J.Parker Mar 05 '19 at 17:47
  • Not in VBA, but the logic for sorting coordinates into a clockwise list can be found: https://stackoverflow.com/a/6989383/6510724 – Emily Alden Mar 05 '19 at 20:35
  • I saw this post as well, but I don't think sorting in this way works for the example geometry that I've shown. Because the wall points move up and down while moving to the right, for example, some points would be incorrectly categorized. – J.Parker Mar 06 '19 at 21:27

0 Answers0