Message 1 of 1
polyline to line segments procedure

Not applicable
07-05-2006
09:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am starting to write a subroutine which will move down a given object (polyline), a specified ammount. However, there is a complication to this, to conserve material cut I need to drop the object gradually instead of down all at once, see attached drawing for clarification.
how ive decided to do this is to get the polylines coordinates and bulge measurements. then redraw the polyline using very small line segments. afterwards I will drop the right number of line segments down in the z plane. heres the code I have for now:
Private Sub subMoveThisDown(ByRef objEnt As AcadEntity, ByVal dblDeltaZ As Double)
Dim varObjCoords As Variant
Dim startpoint(2) As Double
Dim endpoint(2) As Double
Dim dblObjBulge() As Double
Dim dblChord() As Double
Dim dblTheta() As Double
Dim dblRadius() As Double
Dim dblTotalLength As Double
Dim dblCurentLength As Double
Dim intI As Integer
varObjCoords = objEnt.Coordinates
ReDim dblObjBulge(((UBound(varObjCoords) + 1) / 2))
ReDim dblChord(((UBound(varObjCoords) + 1) / 2))
ReDim dblTheta(((UBound(varObjCoords) + 1) / 2))
ReDim dblRadius(((UBound(varObjCoords) + 1) / 2))
For intI = 0 To (((UBound(varObjCoords) + 1) / 2)) - 1
dblObjBulge(intI) = objEnt.GetBulge(intI)
If dblObjBulge(intI) 0 Then
dblTheta(intI) = 4 * Math.Atn(Math.Abs(dblObjBulge(intI)))
dblChord(intI) = ((varObjCoords(intI + 2) - varObjCoords(intI)) ^ 2 + (varObjCoords(intI + 3) - varObjCoords(intI + 1)) ^ 2) ^ (1 / 2)
dblRadius(intI) = 0.5 * dblChord(intI) / (Math.Sin(0.5 * dblTheta(intI)))
Else
dblChord(intI) = ((varObjCoords(intI + 2) - varObjCoords(intI)) ^ 2 + (varObjCoords(intI + 3) - varObjCoords(intI + 1)) ^ 2) ^ (1 / 2)
dblRadius(intI) = 0
dblTheta(intI) = 0
End If
Next
End Sub
As you can see im onto the second step, where i actually break everything up into small lines, any help with this will be appreciated, I will probably post folowups on my own progress. thanks in advance
how ive decided to do this is to get the polylines coordinates and bulge measurements. then redraw the polyline using very small line segments. afterwards I will drop the right number of line segments down in the z plane. heres the code I have for now:
Private Sub subMoveThisDown(ByRef objEnt As AcadEntity, ByVal dblDeltaZ As Double)
Dim varObjCoords As Variant
Dim startpoint(2) As Double
Dim endpoint(2) As Double
Dim dblObjBulge() As Double
Dim dblChord() As Double
Dim dblTheta() As Double
Dim dblRadius() As Double
Dim dblTotalLength As Double
Dim dblCurentLength As Double
Dim intI As Integer
varObjCoords = objEnt.Coordinates
ReDim dblObjBulge(((UBound(varObjCoords) + 1) / 2))
ReDim dblChord(((UBound(varObjCoords) + 1) / 2))
ReDim dblTheta(((UBound(varObjCoords) + 1) / 2))
ReDim dblRadius(((UBound(varObjCoords) + 1) / 2))
For intI = 0 To (((UBound(varObjCoords) + 1) / 2)) - 1
dblObjBulge(intI) = objEnt.GetBulge(intI)
If dblObjBulge(intI) 0 Then
dblTheta(intI) = 4 * Math.Atn(Math.Abs(dblObjBulge(intI)))
dblChord(intI) = ((varObjCoords(intI + 2) - varObjCoords(intI)) ^ 2 + (varObjCoords(intI + 3) - varObjCoords(intI + 1)) ^ 2) ^ (1 / 2)
dblRadius(intI) = 0.5 * dblChord(intI) / (Math.Sin(0.5 * dblTheta(intI)))
Else
dblChord(intI) = ((varObjCoords(intI + 2) - varObjCoords(intI)) ^ 2 + (varObjCoords(intI + 3) - varObjCoords(intI + 1)) ^ 2) ^ (1 / 2)
dblRadius(intI) = 0
dblTheta(intI) = 0
End If
Next
End Sub
As you can see im onto the second step, where i actually break everything up into small lines, any help with this will be appreciated, I will probably post folowups on my own progress. thanks in advance