Line实体的排序问题。
<p>图1,在Acad中任意画4条line实体,顺序为1-3-2-4</p><p> </p><p></p><p>其数据源为</p><p><table cellspacing="0" cellpadding="0" width="504" border="0" style="WIDTH: 378pt; BORDER-COLLAPSE: collapse;"><colgroup><col span="7" width="72" style="WIDTH: 54pt;"></col></colgroup><tbody><tr height="19" style="HEIGHT: 14.25pt;"><td align="right" width="72" height="19" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 54pt; BORDER-BOTTOM: #ece9d8; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">619.5612</font></td><td align="right" width="72" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 54pt; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体"> 451.2518</font></td><td align="right" width="72" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 54pt; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">0</font></td><td align="right" width="72" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 54pt; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体"> 969.7925</font></td><td align="right" width="72" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 54pt; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体"> 543.344</font></td><td align="right" width="72" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 54pt; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体"> 0</font></td><td width="72" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 54pt; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">LineCount1</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td align="right" height="19" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">791.6046</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">846.225</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">0</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">486.4323</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体"> 817.5741</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">0</font></td><td style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">LineCount2</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td align="right" height="19" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">791.6046</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">846.225</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">0</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">969.7925</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">543.344</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">0</font></td><td style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">LineCount3</font></td></tr><tr height="19" style="HEIGHT: 14.25pt;"><td align="right" height="19" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 14.25pt; BACKGROUND-COLOR: transparent;"><font face="宋体">486.4323</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">817.5741</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">0</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">619.5612</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">451.2518</font></td><td align="right" style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">0</font></td><td style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent;"><font face="宋体">LineCount4</font></td></tr></tbody></table></p><p>要求经过对4条line的startpoint和endpoint重新排序,要求顺序为1-2-3-4</p><p> </p><p></p><p>请问各位大侠有什么好的算法和公式。</p><p></p> 本帖最后由 作者 于 2008-6-27 13:57:47 编辑现在要经过首尾相连的算法,使顶点顺序为1-2-3-4
619.56119 451.25179LineCount1
486.43234 817.5741LineCount4
791.60463 846.22501LineCount2
969.79248 543.34399LineCount3
619.56119 451.25179LineCount1
AutocadToTxt文件Sub ll()
ThisDrawing.ActiveTextStyle.fontFile = "c:\windows\fonts\SIMHEI.TTF"
Dim LineData As AcadLine, ArcData As AcadArc
Dim DrawingText As AcadText, DrawingCircle As AcadCircle
Close #1
Open "D:\ls.txt" For Output As #1
Write #1, "m1", "m2", "m3", "m4", "m5", "m6", "m7", "m8", "m9", "m10", "m11", "m12"
Dim Ent As AcadEntity
ii = 1
For Each Ent In ThisDrawing.ModelSpace
m1 = Ent.ObjectName
m2 = Ent.ObjectID
Select Case Ent.ObjectName
Case "AcDbLine"
Set LineData = Ent
With LineData
'Set DrawingCircle = ThisDrawing.ModelSpace.AddCircle(.StartPoint, 35)
m3 = Round(.StartPoint(0), 2)
m4 = Round(.StartPoint(1), 2)
m5 = Round(.StartPoint(2), 2)
m6 = Round(.EndPoint(0), 2)
m7 = Round(.EndPoint(1), 2)
m8 = Round(.EndPoint(2), 2)
ttt = "第" & ii & "点 " & "(" & m3 & "," & m4 & ")"
Set DrawingText = ThisDrawing.ModelSpace.AddText(ttt, .EndPoint, 10)
With DrawingText
.Alignment = acAlignmentMiddleCenter
.TextAlignmentPoint = LineData.StartPoint
m9 = "第" & ii & "点"
ii = ii + 1
End With
End With
End Select
Write #1, m1, m2, m3, m4, m5, m6, m7, m8, m9
Next Ent
Close #1
End Sub
excel排序程序
Sub aaarrr()
Dim rr(3, 5), rrr(4, 2)
For ii = 6 To 9
For jj = 3 To 7
rr(ii - 6, jj - 3) = Sheet1.Cells(ii, jj)
Next jj
Next ii
tt1 = rr(0, 0): tt2 = rr(0, 1)
For gg = 0 To UBound(rrr)
For ii = 0 To UBound(rr)
If ii <> gg Then
If tt1 = rr(ii, 0) And tt2 = rr(ii, 1) Then
rrr(gg, 0) = rr(ii, 3): rrr(gg, 1) = rr(ii, 4):
tt1 = rrr(gg, 0): tt2 = rrr(gg, 1)
ElseIf tt1 = rr(ii, 3) And tt2 = rr(ii, 4) Then
rrr(gg, 0) = rr(ii, 0): rrr(gg, 1) = rr(ii, 1):
tt1 = rrr(gg, 0): tt2 = rrr(gg, 1)
End If
End If
Next ii
For ii = 0 To UBound(rrr)
For jj = 0 To 1
Sheet1.Cells(ii + 16, jj + 6).Value = rrr(ii, jj)
Next jj
Next ii
Next gg
End Sub
页:
[1]