The centerline macro updated!!
The problem of previous code was the centerline can be made only on the rectangular face. Just simple change can make the target face to any polygon with an even number of edges.
Here are changes:
vMidPts is an array to store midpoint location data of edges of the face you selected. I was able to generalize this macro function by replacing hard number with half edge count. The hard number 6 works only on rectangle because 3*4/2=6, where the number of xyz coordinate is 3 and the edge count of rectangle is 4.
Here are changes:
...
For i = 0 To nEdgeCount / 2 - 1
Set swSketchSeg = pModel.CreateLine2( _
vMidPts(i * 3 + 0), vMidPts(i * 3 + 1), 0, _
vMidPts(i * 3 + nEdgeCount * 3 / 2), vMidPts(i * 3 + nEdgeCount * 3 / 2 + 1), 0)
swSketchSeg.ConstructionGeometry = True
Debug.Print "vMidPts-from (" & i & ") = " & _
Format$(vMidPts(i * 3 + 0) * 1000#, "0.0000") & "," & _
Format$(vMidPts(i * 3 + 1) * 1000#, "0.0000") & " mm"
Debug.Print "vMidPts-to (" & i & ") = " & _
Format$(vMidPts(i * 3 + nEdgeCount * 3 / 2) * 1000#, "0.0000") & "," & _
Format$(vMidPts(i * 3 + nEdgeCount * 3 / 2 + 1) * 1000#, "0.0000") & " mm"
Next i
...
The red line above was updated from:
vMidPts(i * 3 + 6), vMidPts(i * 3 + 7), 0)
vMidPts is an array to store midpoint location data of edges of the face you selected. I was able to generalize this macro function by replacing hard number with half edge count. The hard number 6 works only on rectangle because 3*4/2=6, where the number of xyz coordinate is 3 and the edge count of rectangle is 4.
Comments