- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2004-4-22 12:13:00
|
显示全部楼层
Public Class TlsEntity Inherits TlsObject Private pTlsVals As New Collection '变量集合 Private Shared pSubs As New Collection '函数集合 Private Shared pBlock As Autodesk.AutoCAD.Interop.Common.AcadBlock Private pMirrorStart, pArrayStart As Short Private dDataType(50) As Short, dData(50) As Object Public Sub New() Dim i As Object Dim pData As TlsData Name = "TlsEntity" pData = New TlsData : pData.sData = "0,0,0" : pTlsVals.Add(pData, "PS") '定义初始点 pData = New TlsData : pData.sData = "0" : pTlsVals.Add(pData, "Start") '旋转或镜像开始 pData = New TlsData : pData.sData = "0" : pTlsVals.Add(pData, "End") '旋转或镜像结束 pData = New TlsData : pData.sData = "01" : pTlsVals.Add(pData, "CSX") pData = New TlsData : pData.sData = "02" : pTlsVals.Add(pData, "XSX") pData = New TlsData : pData.sData = "03" : pTlsVals.Add(pData, "ZXX") pData = New TlsData : pData.sData = "04" : pTlsVals.Add(pData, "XX") '图层定义 dDataType(0) = 1001 : dData(0) = "EntityDefine" dDataType(1) = 1000 : dData(1) = "" For i = 2 To 30 dDataType(i) = 1040 : dData(i) = 0 Next i For i = 31 To 50 dDataType(i) = 1070 : dData(i) = 0 Next i '扩张数据初始化
End Sub Public Sub Init() '块初始化 Dim pnt(2) As Double OpenFile() pBlock = pACadDoc.Blocks.Add(pnt, "*U") End Sub Public Property EntityName() As String '实体名属性 Get EntityName = dData(1) End Get Set(ByVal Value As String) dData(1) = Value End Set End Property Private Property XData(ByVal Index As Short) As Double '实体参数属性 Get XData = dData(Index + 10) End Get Set(ByVal Value As Double) dData(Index + 10) = Value End Set End Property Protected Overrides Sub Save() MyBase.Save() pObj.SetXData(dDataType, dData) End Sub Public Overrides Sub Insert() Dim pnt As Object Try pnt = pACadDoc.Utility.GetPoint(, "请输入插入点:") pObj = pACadMSpace.InsertBlock(pnt, pBlock.Name, 1, 1, 1, 0) pObj.Rotate(pnt, pACadDoc.Utility.GetAngle(pnt, "请输入旋转角度:")) Save() Catch ex As Exception End Try End Sub Private Sub StrCal(ByVal String1 As Object) '函数运算器 Dim i As Object Dim pCals As Collection Dim pStrack1 As New Collection Dim pStrack2 As Collection Try pCals = CutStr(String1) '分解一行语句 For i = 1 To pCals.Count If pCals(i).sData <> ")" Then '不是)时顺序入栈 pStrack1.Add(pCals(i)) Else '遇")"时顺序出栈到"(" pStrack2 = New Collection Do While pStrack1(pStrack1.Count).sData <> "(" pStrack2.Add(pStrack1(pStrack1.Count)) pStrack1.Remove(pStrack1.Count) Loop pStrack1.Remove(pStrack1.Count) pStrack1.Add(GetVal(pStrack2)) '计算结果并入栈 End If Next i Catch ex As Exception End Try End Sub Private Function CutStr(ByVal String1 As Object) As Collection '分解一行语句 Dim i, j As Object Dim pStrack As Object Dim pCals As New Collection Dim pData As TlsData Try pStrack = Split(String1, " ") '先按空格分解 If Not IsArray(pStrack) Then Exit Try For Each i In pStrack If InStr(1, i, "(") = 1 Then '有"("时 pData = New TlsData pData.sData = "(" pCals.Add(pData) If RightStr(i, "(") <> "" Then pData = New TlsData pData.sData = RightStr(i, "(") pCals.Add(pData) End If ElseIf InStr(1, i, ")") > 1 Then '有")"时 pData = New TlsData pData.sData = LeftStr(i, ")") pCals.Add(pData) For j = 1 To Len(RightStr(i, ")")) + 1 pData = New TlsData pData.sData = ")" pCals.Add(pData) Next j ElseIf Trim(i) <> "" Then '去除空字符 pData = New TlsData pData.sData = i pCals.Add(pData) End If Next i Catch ex As Exception Finally CutStr = pCals End Try End Function
|
|