- UID
- 433376
- 积分
- 61
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2006-5-6
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
自动添加当前日期的问题我已解决,现拿出来和大家分享:
Private Sub AcadDocument_Activate()
Dim TextObj As AcadText
Dim TextString As String
Dim InsPnt(0 To 2) As Double
Dim Height As Double
Set FontStyle = ThisDrawing.TextStyles.Add("宋体长型0.67")
FontStyle.SetFont "宋体", False, False, 0, 0
If Not Err Then ThisDrawing.ActiveTextStyle = FontStyle
FontStyle.Height = 6
FontStyle.Width = 0.4
ThisDrawing.ActiveTextStyle = FontStyle
InsPnt(0) = 259: InsPnt(1) = 1.8: InsPnt(2) = 0
Height = 6.5
s = Format(ConvertJulianDate(ThisDrawing.GetVariable("DATE")), "YYYY.MM.DD")
TextString = s
Set TextObj = ThisDrawing.ModelSpace.AddText(TextString, InsPnt, Height)
End Sub
Private Sub AcadDocument_Deactivate()
Dim SSetObj As AcadSelectionSet
Set SSetObj = ThisDrawing.SelectionSets.Add("DelDateText")
'创建过滤器Text(单行文本)、Mtext(多行文本)
Dim fType(0) As Integer
Dim fData(0) As Variant
fType(0) = 0
fData(0) = "Text,Mtext"
'选择全部的Text、Mtext
SSetObj.Select acSelectionSetAll, , , fType, fData
If SSetObj.Count <> 0 Then
Dim i As Integer
For i = 0 To SSetObj.Count - 1
'Text和Mtext中显示的是TextString
If SSetObj(i).TextString = s Then SSetObj(i).Delete
Next
End If
SSetObj.Delete
Set SSetObj = Nothing
End Sub
以下加载在模块内:
Public s As String '申明S(存放当前日期)全局字符变量,这点很重要。两过程共用此变量!
Public Function ConvertJulianDate(julianDate As Double) As Date
ConvertJulianDate = julianDate - 2415019
End Function
感谢晓东CAD!感谢明经通道! 黄玉宏 2006.6.1 |
|