wholin 发表于 2006-10-28 16:53:00

huaiyu,请进,在线等

本帖最后由 作者 于 2006-10-30 14:24:58 编辑 <br /><br /> <P>在多段线的每个顶点都加一个圆,圆心就是顶点,半径为2</P>
<P>在vba中如何实现呀?</P>
<P>大家帮手,&nbsp; 谢谢</P>

HuaiYu 发表于 2006-10-28 23:30:00

<P>这样对 Coordinates 的遍历来得到的</P>
<P>Sub Test5()<BR>Dim objSel As AcadEntity<BR>Dim pt As ACAD_POINT<BR>On Error GoTo exitSel<BR>ThisDrawing.Utility.GetEntity objSel, pt, "Pick a text"<BR>'If TypeOf objSel Is AcDbText Then<BR>If objSel.ObjectName &lt;&gt; "AcDbPolyline" Then<BR>&nbsp;ThisDrawing.Utility.Prompt "选择的不是 AcDbPolyline,请重新选择!"<BR>&nbsp;Exit Sub<BR>End If<BR>'Dim vv As AcadPolyline<BR>Dim pts As Variant<BR>pts = objSel.Coordinates<BR>Dim i As Integer<BR>i = 1<BR>Dim ptCir(0 To 2) As Double<BR>Dim cir As AcadCircle<BR>For Each pt In pts<BR>&nbsp;If i = 2 Then<BR>&nbsp;ptCir(1) = pt<BR>&nbsp;ptCir(2) = 0#<BR>&nbsp;Set cir = ThisDrawing.ModelSpace.AddCircle(ptCir, 2#)<BR>&nbsp;i = 1<BR>&nbsp;Else<BR>&nbsp;ptCir(0) = pt<BR>&nbsp;i = i + 1<BR>&nbsp;End If<BR>&nbsp;<BR>Next pt</P>
<P>exitSel:<BR>End Sub</P>

wholin 发表于 2006-10-30 13:59:00

huaiyu,谢谢你的精彩解答,我试一下你的办法

wholin 发表于 2006-10-30 14:23:00

<P>huaiyu,我用你的方法时发现两个问题:</P>
<P>&nbsp; 1.有圆弧的地方,凸点没能加圆,其它的顶点都可以正确的加上去</P>
<P>&nbsp; 2.你用的是选择一个多段线</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.Utility.GetEntity objSel, pt, "Pick a text"<BR>&nbsp;&nbsp;&nbsp;&nbsp; 我现在想改成在一个选择集中的所有多段线的顶点都要加一个同样的圆</P>
<P>不知你能不能再帮忙解答一下,在线等.....</P>
页: [1]
查看完整版本: huaiyu,请进,在线等