?? 在excle中數值當作坐標值,在已打開的某autocad文件中生成一段polyline.txt
字號:
1 先 定 義 Excel對 象 :
public xxx as object
set xxx=createobject("excel.application")
xxx.visible=true
......
......
Get the polyline data from Excel's columns. Here we say the array is polylinepoints().
2 定 義 AutoCAD的 對 象 :
On Error Resume Next
Set AcadApp = GetObject(, "AutoCAD.Application")
If Err.Number = 429 Then
Set AcadApp = CreateObject("AutoCAD.Application")
Err.Clear
End If
Set AcadDoc = AcadApp.ActiveDocument
Set MoSpace = AcadDoc.ModelSpace
3 畫 polyline
dim i as integer, x , y, stepx, stepy
x,y為 輸 入 的 第 一 個 點 坐 標 , stepx,stepy為 相 對 坐 標
'確 定 第 一 個 點
x=inputbox("first x?")
y=inputbox("first y?")
'確 定 相 對 坐 標
stepx=polylinepoints(0)-x
stepy=polylinepoints(0)-y
for i=0 to ubound(polylinepoints)-1
if i mod 2 =0 then
polylinepoints(i)=polylinepoints(i)-stepx
else
polylinepoints(i)=polylinepoints(i)-stepy
end if
next i
mospace.addpolyline(polylinepoints)
對 于 polyline,其 輸 入 參 數 為 一 個 數 組 , 如 果 有 四 個 點 , 則 該 數 組 有 8個 元 元 素 , 從 0至 7。
AUTOCAD很 長 時 間 未 動 了 ,不 知 道 對 不 對 。 以 上 例 子 未 經 試 驗 ......
<END>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -