刚找了一段VBA程序不能编译,大侠给修改一下吧
本帖最后由 作者 于 2008-6-14 11:20:07 编辑 <br /><br /> <p>本人新手,刚在本版找了一段VBA程序编译不了,请大侠帮忙解决!谢谢</p><p>本段程序是关于<strong>求解多个不规则封闭图形的总面积、总周长、个数的</strong></p><p><strong>Public Sub GetTolArea()<br/> ThisDrawing.SendCommand "(vl-load-com)" & vbCr<br/> Dim CurveObj As cruve<br/> Set CurveObj = New cruve<br/> Dim VlaxObj As VLAX<br/> Set VlaxObj = New VLAX<br/> Dim OutEnt As AcadEntity<br/> Dim Pnt As Variant<br/> ThisDrawing.Utility.GetEntity OutEnt, Pnt, "选择外框:"<br/> Dim MinBox As Variant<br/> Dim MaxBox As Variant<br/> Dim OutArea As Double<br/> Dim OutLeng As Double<br/> OutEnt.GetBoundingBox MinBox, MaxBox<br/> If OutEnt.ObjectName = "AcDbRegion" Then<br/> OutArea = OutEnt.Area<br/> OutLeng = OutEnt.Perimeter<br/> Else<br/> Set CurveObj.Entity = OutEnt<br/> OutArea = CurveObj.Area<br/> OutLeng = CurveObj.Length<br/> End If<br/> 'Set CurveObj.Entity = OutEnt<br/> Dim ss As AcadSelectionSet<br/> Set ss = CreatSSet<br/> Dim FType(0) As Integer<br/> Dim FData(0) As Variant<br/> FType(0) = 0<br/> FData(0) = "SPLINE"<br/> ss.Select acSelectionSetWindow, MinBox, MaxBox, FType, FData<br/> 'Debug.Print ss.Count<br/> Dim i As Integer<br/> Dim InArea() As Double<br/> Dim InLeng() As Double<br/> Dim j As Integer<br/> Dim Ent As AcadEntity<br/> ReDim Preserve InArea(0) As Double<br/> ReDim Preserve InLeng(0) As Double<br/> For i = 0 To ss.Count - 1<br/> If ss.Item(i).ObjectID > OutEnt.ObjectID Then<br/> Set Ent = ss(i)<br/> Set CurveObj.Entity = Ent<br/> VlaxObj.EvalLispExpression "(gc)"<br/> If i > 0 Then<br/> j = UBound(InArea) + 1<br/> ReDim Preserve InArea(j) As Double<br/> ReDim Preserve InLeng(j) As Double<br/> InArea(j) = CurveObj.Area<br/> InLeng(j) = CurveObj.Length<br/> Else<br/> InArea(0) = CurveObj.Area<br/> InLeng(0) = CurveObj.Length<br/> End If<br/> End If<br/> Next<br/> Dim TolArea As Double<br/> Dim TolLeng As Double<br/> Dim AreaPer As Double<br/> Dim dispMsg As String<br/> dispMsg = "外框的面积为:" & OutArea & ",周长为:" & OutLeng & vbCrLf & vbCrLf<br/> dispMsg = dispMsg & "内部曲线的面积及周长如下:" & vbCrLf<br/> For i = 0 To UBound(InArea)<br/> dispMsg = dispMsg & "曲线" & i & "面积:" & InArea(i) & ",周长:" & InLeng(i) & vbCrLf<br/> <br/> TolArea = TolArea + InArea(i)<br/> TolLeng = TolLeng + InLeng(i)<br/> Next<br/> dispMsg = dispMsg & vbCrLf<br/> dispMsg = dispMsg & "总面积为:" & TolArea & " 总周长为:" & TolLeng & vbCrLf & vbCrLf<br/> AreaPer = TolArea / OutArea * 100<br/> dispMsg = dispMsg & "内部曲线面积总各占外框面积的百分比:" & AreaPer & "%"<br/> 'MsgBox dispMsg<br/> ThisDrawing.Utility.Prompt dispMsg<br/>End Sub<br/>Function CreatSSet()<br/> Dim ss As AcadSelectionSet<br/> On Error Resume Next<br/> Set ss = ThisDrawing.SelectionSets.Add("mccad")<br/> If Err Then<br/> Err.Clear<br/> Set ss = ThisDrawing.SelectionSets("mccad")<br/> ss.Clear<br/> End If<br/> Set CreatSSet = ss<br/>End Function</strong></p><p><strong><br/></strong></p>
页:
[1]