sdo7758258 发表于 2004-3-16 21:44:00

求助

请问:以下程序是用什么编的,在CAD中如何使用?


Sub opsum()<BR>Dim ss As AcadSelectionSet<BR>Set ss = GetSelSet<BR>Dim i As Integer<BR>Dim a As Double<BR>Dim ent As AcadEntity<BR>For Each ent In ss<BR>a = ent.textString<BR>e = a<BR>d = d + e<BR>Dim ent2height As String<BR>ent2height = ent.height<BR>Next<BR>f = FormatNumber(d, 3, vbture, , vbFalse)<BR>Dim text2 As String<BR>ThisDrawing.Utility.InitializeUserInput 0, "1 2"<BR>text2 = ThisDrawing.Utility.GetKeyword(vbCrLf &amp; 选项"[更改(1)/插入(2)](1): ")<BR>If text2 = "" Or text2 = "1" Then text2 = "1"<BR>If text2 = "1" Then<BR>Dim ent1 As AcadEntity<BR>ThisDrawing.Utility.GetEntity ent1, pt1, "选择更改数字:"<BR>ent1.textString = f<BR>End If<BR>If text2 = "2" Then<BR>Dim pt2 As Variant<BR>Dim ent2 As AcadText<BR>pt2 = ThisDrawing.Utility.GetPoint(, "插入:")<BR>Set ent2 = ThisDrawing.ModelSpace.AddText(f, pt2, ent2height)<BR>End If<BR>End Sub


Sub opmul()<BR>Dim ss As AcadSelectionSet<BR>Set ss = GetSelSet<BR>Dim ent As AcadEntity<BR>Dim a As Double<BR>Dim d As Double<BR>d = 1<BR>For Each ent In ss<BR>a = ent.textString<BR>e = a<BR>d = d * e<BR>Dim height As String<BR>height = ent.height<BR>Next<BR>f = FormatNumber(d, 3, vbture, , vbFalse)<BR>On Error Resume Next<BR>ThisDrawing.Utility.InitializeUserInput 0, "1 2"<BR>text2 = ThisDrawing.Utility.GetKeyword(vbCrLf &amp; "选项[更改(1)/插入(2)](1): ")<BR>If text2 = "" Or text2 = "1" Then text2 = "1"<BR>If text2 = "1" Then<BR>Dim ent1 As AcadEntity<BR>ThisDrawing.Utility.GetEntity ent1, pt1, "选择更改数字:"<BR>ent1.textString = f<BR>End If<BR>If text2 = "2" Then<BR>Dim pt2 As Variant<BR>Dim ent2 As AcadText<BR>pt2 = ThisDrawing.Utility.GetPoint(, "插入点:")<BR>Set ent2 = ThisDrawing.ModelSpace.AddText(f, pt2, height)<BR>End If<BR>End Sub


Function GetSelSet() As AcadSelectionSet<BR>Dim ss As AcadSelectionSet<BR>Dim ssName As String<BR>ssName = "PICKFIRST"<BR>On Error Resume Next<BR>Set ss = ThisDrawing.SelectionSets.add(ssName)<BR>If Err Then<BR>Set ss = ThisDrawing.SelectionSets(ssName)<BR>ss.Delete<BR>End If<BR>Set ss = ThisDrawing.PickfirstSelectionSet<BR>If ss.Count = 0 Then<BR>Set ss = ThisDrawing.SelectionSets(ssName)<BR>If Err Then Set ss = ThisDrawing.SelectionSets.add(ssName)<BR>ss.Clear<BR>ss.SelectOnScreen<BR>End If<BR>Set GetSelSet = ss<BR>ThisDrawing.SetVariable "filedia", 1<BR>End Function<BR>

efan2000 发表于 2004-3-17 13:22:00

是VBA的程序,从代码上看是对文字进行修改和插入的操作,可以直接在VB编辑器中粘贴运行。
页: [1]
查看完整版本: 求助