- 积分
- 73549
- 明经币
- 个
- 注册时间
- 2001-6-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-4-27 22:02:00
|
显示全部楼层
对于程序生成的对象,在对象生成的时候就可以取得对象,而不需要再经过选择集来选定。如你程序中绘制活塞图中的一段就可以这样写:
- '画图
- Dim varLines(20) As AcadEntity
- Set varLines(0) = AddLine(ImPoint(0), ImPoint(1))
- Set varLines(1) = AddLine(ImPoint(1), ImPoint(2))
- Set varLines(2) = AddLine(ImPoint(2), ImPoint(3))
- Set varLines(3) = AddLine(ImPoint(3), ImPoint(4))
- Set varLines(4) = AddLine(ImPoint(4), ImPoint(5))
- Set varLines(5) = AddLine(ImPoint(5), ImPoint(6))
- Set varLines(6) = AddLine(ImPoint(6), ImPoint(7))
- Set varLines(7) = AddLine(ImPoint(7), ImPoint(8))
- Set varLines(8) = AddLine(ImPoint(8), ImPoint(9))
- Set varLines(9) = AddLine(ImPoint(9), ImPoint(10))
- Set varLines(10) = AddLine(ImPoint(10), ImPoint(11))
- Set varLines(11) = AddLine(ImPoint(11), ImPoint(12))
- Set varLines(12) = AddLine(ImPoint(15), ImPoint(14))
- Set varLines(13) = AddLine(ImPoint(13), ImPoint(15))
- Set varLines(14) = AddLine(ImPoint(15), ImPoint(17))
- Set varLines(15) = AddLine(ImPoint(16), ImPoint(17))
- Set varLines(16) = AddLine(ImPoint(17), ImPoint(18))
- Set varLines(17) = AddLine(ImPoint(10), ImPoint(19))
- Set varLines(18) = AddLine(ImPoint(19), ImPoint(20))
- Set varLines(19) = AddLine(ImPoint(20), ImPoint(21))
- '切换到虚线 图层
- For Each objLayer In ThisDrawing.Layers
- If objLayer.name = "虚线" Then
- ThisDrawing.ActiveLayer = objLayer
- End If
- Next
- Set varLines(20) = AddLine(ImPoint(13), ImPoint(18))
- '切换到0 图层
- For Each objLayer In ThisDrawing.Layers
- If objLayer.name = "0" Then
- ThisDrawing.ActiveLayer = objLayer
- End If
- Next
-
- ' 镜像
- Dim i As Integer
- For i = 0 To 20
- varLines(i).Mirror ImPoint(0), ImPoint(12)
- Next i
- End
可以看到,这里用了一个varLine数组来保存生成的直线,这样在最后就可以使用该数组来镜像这样对象。
另外,你的程序好多是重复的内容,如生成图框其它都是一样,只是名称不同,所以将其做为一个函数最好,不然这样给人感觉很乱。 |
|