求助VBA。
<P>怎样能将CAD图形中特定的数字(单行的)选择,然后自动相加,结果(单行的)放在特定的位子?如何做?请教各位高手。</P> <P>把想操作的数字 放进一个选择集中</P><P>遍历他 依次相加 </P>
<P>最后输出结果。</P> <P>2楼你说的我明白,可是我是CAD VBA新手,虽然有VB的基础,可是对于CAD VBA,还是很陌生,可否写出来,我可以看懂的。谢谢。</P> <P>我也是啊!请高手指点</P>
<P> </P> 本帖最后由 作者 于 2006-7-19 9:25:03 编辑 <br /><br /> <P>Private Sub CommandButton1_Click()<BR> <BR> On Error Resume Next<BR> Dim txtObJ As AcadText<BR> Dim txtInsPos(0 To 2) As Double<BR> Dim Sum As Double<BR> Dim txtHeight As Double<BR> Dim SsetObj As AcadSelectionSet<BR> Dim Entry As AcadEntity<BR> <BR> Set SsetObj = ThisDrawing.SelectionSets("Sset1")<BR> If Err Then Set SsetObj = ThisDrawing.SelectionSets.Add("Sset1")<BR> SsetObj.Clear<BR> <BR> Me.Hide<BR> SsetObj.SelectOnScreen<BR> <BR> Sum = 0<BR> txtHeight = 0<BR> <BR> For Each Entry In SsetObj<BR> If TypeName(Entry) Like "IAcad*Text*" Then Sum = Sum + Entry.TextString<BR> Next Entry<BR> <BR> txtInsPos(0) = 0<BR> txtInsPos(1) = 0<BR> txtInsPos(2) = 0<BR> txtHeight = 10<BR> <BR> Set txtObJ = ThisDrawing.ModelSpace.AddText(Str(Sum), txtInsPos, txtHeight)<BR> <BR> SsetObj.Clear<BR> MsgBox "计算结果显示在在(0,0,0)处"<BR>End Sub<BR></P>
<P></P>
<P></P>
页:
[1]