WEB开发网
开发学院图形图像AutoCAD 利用VBA编程实现从EXCEL表到AUTOCAD表转换 阅读

利用VBA编程实现从EXCEL表到AUTOCAD表转换

 2006-04-03 09:48:40 来源:WEB开发网   
核心提示: 在AutoCAD中,线条有多种,利用VBA编程实现从EXCEL表到AUTOCAD表转换(3),考虑能够方便控制线条属性,选用了多义线

---- 在AutoCAD中,线条有多种,考虑能够方便控制线条属性,选用了多义线。具体命令如下: RetVal = object.AddLightWeightPolyline(VerticesList)

---- 下面的程序演示表格线条读取和画表格线的具体过程。

Sub hxw()
Dim a as interger ‘表格的最大行数
Dim b as interger ‘表格的最大列数
Dim xinit as double ‘插入点x坐标
Dim yinit as double ‘插入点y坐标
Dim zinit as double ‘插入点z坐标
Dim xinsert as double ‘当前单元格的左上角点的x左标
Dim yinsert as double ’当前单元格的左上角点的y左标
Dim ptarray (0 to 2) as double
Dim x as integer
Dim y as integer
For x =1 to a
For y=1 to b
Set c = xlsheet.Range(zh(y) + Trim(Str(x)))
‘以行号、列号获得单元格地址
Set ma = c.MergeArea
‘求出单元格C的合并单元格地址
If Left(Trim(ma.Address), 4) = Trim(c.Address) Then
假如c.mergearea的绝对地址,如果前4个字符与c单元格的地址相同
xl = "A1:" + ma.Address
xh = xlsheet.Range(ma.Address).Width
yh = xlsheet.Range(ma.Address).Height
Set xlrange = xlsheet.Range(xl)
xinsert = xlrange.Width - xh
yinsert = xlrange.Height - yh
xpoint = xinit + xinsert
ypoint = yinit - yinsert
If x = 1 Then
If ma.Borders(xlEdgeTop).LineStyle
<> xlNone Then
ptArray(0) = xpoint
‘第一点坐标(数组下标 0 and 1)
ptArray(1) = ypoint
ptArray(2) = xpoint + xh
‘第二点坐标(数组下标 2 and 3)
ptArray(3) = ypoint
End If

上一页  1 2 3 4  下一页

Tags:利用 VBA 编程

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接