明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1966|回复: 1

求助

[复制链接]
发表于 2004-3-16 21:44 | 显示全部楼层 |阅读模式
请问:以下程序是用什么编的,在CAD中如何使用? Sub opsum()
Dim ss As AcadSelectionSet
Set ss = GetSelSet
Dim i As Integer
Dim a As Double
Dim ent As AcadEntity
For Each ent In ss
a = ent.textString
e = a
d = d + e
Dim ent2height As String
ent2height = ent.height
Next
f = FormatNumber(d, 3, vbture, , vbFalse)
Dim text2 As String
ThisDrawing.Utility.InitializeUserInput 0, "1 2"
text2 = ThisDrawing.Utility.GetKeyword(vbCrLf & 选项"[更改(1)/插入(2)](1): ")
If text2 = "" Or text2 = "1" Then text2 = "1"
If text2 = "1" Then
Dim ent1 As AcadEntity
ThisDrawing.Utility.GetEntity ent1, pt1, "选择更改数字:"
ent1.textString = f
End If
If text2 = "2" Then
Dim pt2 As Variant
Dim ent2 As AcadText
pt2 = ThisDrawing.Utility.GetPoint(, "插入:")
Set ent2 = ThisDrawing.ModelSpace.AddText(f, pt2, ent2height)
End If
End Sub Sub opmul()
Dim ss As AcadSelectionSet
Set ss = GetSelSet
Dim ent As AcadEntity
Dim a As Double
Dim d As Double
d = 1
For Each ent In ss
a = ent.textString
e = a
d = d * e
Dim height As String
height = ent.height
Next
f = FormatNumber(d, 3, vbture, , vbFalse)
On Error Resume Next
ThisDrawing.Utility.InitializeUserInput 0, "1 2"
text2 = ThisDrawing.Utility.GetKeyword(vbCrLf & "选项[更改(1)/插入(2)](1): ")
If text2 = "" Or text2 = "1" Then text2 = "1"
If text2 = "1" Then
Dim ent1 As AcadEntity
ThisDrawing.Utility.GetEntity ent1, pt1, "选择更改数字:"
ent1.textString = f
End If
If text2 = "2" Then
Dim pt2 As Variant
Dim ent2 As AcadText
pt2 = ThisDrawing.Utility.GetPoint(, "插入点:")
Set ent2 = ThisDrawing.ModelSpace.AddText(f, pt2, height)
End If
End Sub Function GetSelSet() As AcadSelectionSet
Dim ss As AcadSelectionSet
Dim ssName As String
ssName = "PICKFIRST"
On Error Resume Next
Set ss = ThisDrawing.SelectionSets.add(ssName)
If Err Then
Set ss = ThisDrawing.SelectionSets(ssName)
ss.Delete
End If
Set ss = ThisDrawing.PickfirstSelectionSet
If ss.Count = 0 Then
Set ss = ThisDrawing.SelectionSets(ssName)
If Err Then Set ss = ThisDrawing.SelectionSets.add(ssName)
ss.Clear
ss.SelectOnScreen
End If
Set GetSelSet = ss
ThisDrawing.SetVariable "filedia", 1
End Function
发表于 2004-3-17 13:22 | 显示全部楼层
是VBA的程序,从代码上看是对文字进行修改和插入的操作,可以直接在VB编辑器中粘贴运行。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-18 01:01 , Processed in 0.209243 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表