兰州人 发表于 2009-8-20 21:52:00

常用材料表格式。

Sub MaterialTitle()<br/>&nbsp; Dim cadApp As AcadApplication<br/>&nbsp; Set cadApp = ConnectCad<br/>&nbsp; Dim xArr, textTitle, heightTitle, materialRow<br/>&nbsp; xArr = Array(0, 20, 50, 97, 107, 137, 148.5, 160, 171.5, 180)<br/>&nbsp; textitle = Array("件&nbsp; 号", "图号或标准号", "名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 称", "数量", "材&nbsp;&nbsp;&nbsp; 料", "单", "总", "质 量(kg)", "备&nbsp;&nbsp; 注")<br/>&nbsp; Dim pp0(2) As Double, pp1(2) As Double<br/>&nbsp;&nbsp;&nbsp; materialRow = 13<br/>&nbsp;&nbsp;&nbsp; 'heightTitle = 14 + 8 * materialRow<br/>&nbsp;&nbsp;&nbsp; pp1(0) = 180<br/>&nbsp; With cadApp.ActiveDocument.ModelSpace<br/>&nbsp;&nbsp;&nbsp; For ii = 0 To materialRow + 2<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If ii = 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; heightTitle = 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf ii = 1 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; heightTitle = 14<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; heightTitle = heightTitle + 8<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pp0(1) = heightTitle:<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pp1(1) = pp0(1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set objLine = .AddLine(pp0, pp1)<br/>&nbsp;&nbsp;&nbsp; Next ii<br/>&nbsp;&nbsp;&nbsp; ''<br/>&nbsp;&nbsp;&nbsp; Dim p0(2) As Double, p1(2) As Double<br/>&nbsp;&nbsp;&nbsp; p0(1) = 0: p1(1) = heightTitle<br/>&nbsp;&nbsp;&nbsp; For jj = 0 To UBound(xArr)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p0(0) = xArr(jj): p1(0) = p0(0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set objLine = .AddLine(p0, p1)<br/>&nbsp;&nbsp;&nbsp; Next jj<br/>&nbsp; End With<br/>End Sub<br/>

新鲜8 发表于 2018-11-12 15:21:27

Set cadApp = Conne   错误要求对象怎么回事
   
页: [1]
查看完整版本: 常用材料表格式。