kevinchan 发表于 2004-11-17 21:47:00

mccad发表于2004-11-17 21:41:00static/image/common/back.gif把圆直接改成圆环,是不可能的。只有通过读取圆的属性,(如圆心位置及半径),然后删除,重新按照其大小生成圆环。

<BR>针对上面的源代码,应加怎样的代码来读取和生成呢?

雪山飞狐_lzh 发表于 2004-11-17 21:49:00

Sub test()<BR>On Error Resume Next<BR>Dim ss As AcadSelectionSet<BR>ThisDrawing.SelectionSets("Test").Delete<BR>Set ss = ThisDrawing.SelectionSets.Add("Test")<BR>Dim ft(0) As Integer, fd(0)<BR>ft(0) = 0: fd(0) = "Circle"<BR>ss.SelectOnScreen ft, fd<BR>For Each i In ss<BR>Cir2LW i, 1<BR>Next i<BR>End Sub


Sub Cir2LW(ByVal oCircle, ByVal Width As Double)<BR>Dim pnt<BR>Dim r As Double<BR>Dim pnts(3) As Double<BR>Dim oLW As AcadLWPolyline<BR>pnt = oCircle.Center<BR>r = oCircle.radius<BR>pnts(0) = pnt(0) - r: pnts(1) = pnt(1)<BR>pnts(2) = pnt(0) + r: pnts(3) = pnt(1)<BR>Set oLW = ThisDrawing.ModelSpace.AddLightWeightPolyline(pnts)<BR>oLW.Closed = True<BR>oLW.SetBulge 0, 1<BR>oLW.SetBulge 1, 1<BR>oLW.SetWidth 0, Width, Width<BR>oLW.SetWidth 1, Width, Width<BR>oLW.Update<BR>oCircle.Delete<BR>End Sub<BR>

mccad 发表于 2004-11-17 21:50:00

你的程序只需把Set circ = ThisDrawing.ModelSpace.AddCircle(centerpt, radius)<BR>改成6楼所说的方法就可以了,这应该很容易完成,又何必在画完圆后再改成圆环呢?

kevinchan 发表于 2004-11-17 21:51:00

恩, 谢谢!!!

kevinchan 发表于 2004-11-17 21:53:00

我刚才试了改不成功,偶比较菜,老大可以帮我修改一下源码吗?


谢谢!

雪山飞狐_lzh 发表于 2004-11-17 22:06:00

加一个函数


Sub AddDonut(ByVal Center, ByVal Radius As Double, ByVal Width As Double)<BR>                       Dim oLW As AcadLWPolyline<BR>                       Dim pnts(3) As Double<BR>                       pnts(0) = Center(0) - Radius: pnts(1) = Center(1)<BR>                       pnts(2) = Center(0) + Radius: pnts(3) = Center(1)<BR>                       Set oLW = ThisDrawing.ModelSpace.AddLightWeightPolyline(pnts)<BR>                       oLW.Closed = True<BR>                       oLW.SetBulge 0, 1<BR>                       oLW.SetBulge 1, 1<BR>                       oLW.SetWidth 0, Width, Width<BR>                       oLW.SetWidth 1, Width, Width<BR>                       oLW.Update<BR>End Sub





Set circ = ThisDrawing.ModelSpace.AddCircle(centerpt, radius)


改为


AddDonut centerpt,radius, 1<BR>

kevinchan 发表于 2004-11-17 22:37:00

搞定,非常感谢lzh和mccad的帮忙!
页: 1 [2]
查看完整版本: 如何修改成圆环(donut)-付源代码