需要解析CAD文件的構(gòu)成 然后根據(jù)規(guī)則繪制 說(shuō)白點(diǎn)CAD文件是人家公司定義的一個(gè)文件格式 里面保存的不是圖形 而是圖形的繪制規(guī)則 程序AutoCad打開(kāi)文件的時(shí)候是讀取文件里面描寫的繪制規(guī)則繪制圖案的 你了解了CAD文件的構(gòu)成后就可以自己寫代碼繪制圖形了(具體CAD圖形構(gòu)成沒(méi)研究過(guò) 你可以用記事本打開(kāi)一個(gè)CAD的圖形交換文件.Dxf 可以看到 這個(gè)文件是由圖層說(shuō)明和很多點(diǎn)坐標(biāo)組成的)
創(chuàng)新互聯(lián)主打移動(dòng)網(wǎng)站、網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì)、網(wǎng)站改版、網(wǎng)絡(luò)推廣、網(wǎng)站維護(hù)、域名申請(qǐng)、等互聯(lián)網(wǎng)信息服務(wù),為各行業(yè)提供服務(wù)。在技術(shù)實(shí)力的保障下,我們?yōu)榭蛻舫兄Z穩(wěn)定,放心的服務(wù),根據(jù)網(wǎng)站的內(nèi)容與功能再?zèng)Q定采用什么樣的設(shè)計(jì)。最后,要實(shí)現(xiàn)符合網(wǎng)站需求的內(nèi)容、功能與設(shè)計(jì),我們還會(huì)規(guī)劃穩(wěn)定安全的技術(shù)方案做保障。
你去查查書吧,書上挺詳細(xì)的,在這說(shuō)不好說(shuō),你先在項(xiàng)目里引用。然后 Dim acadapp As AcadApplication Dim acaddoc As AcadDocument On Error Resume Next AcadApp = GetObject(, "AutoCAD.Application") If Err.Number Then Err.Clear() AcadApp = CreateObject("AutoCAD.Application") If Err.Number Then MsgBox("不能運(yùn)行AutoCAD,請(qǐng)檢查是否安裝了AutoCAD") Exit Sub End If End If AcadApp.Visible = True '界面可視
這個(gè)是vb.net教材里面的吧,我也是前兩天剛下的。遇到類似的問(wèn)題,下面是我的解決辦法
首先要參考引用Autodesk.AutoCAD.Interop.dll還有Autodesk.AutoCAD.Interop.Common.dll
然后代碼有兩處也需要相應(yīng)修改,我用的是.NET 的 vb2008
'Dim AcadApp As AutoCAD.AcadApplication
Dim AcadApp As Autodesk.AutoCAD.Interop.AcadApplication
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call 連接AutoCAD()
End Sub
Sub 連接AutoCAD()
On Error Resume Next
AcadApp = GetObject(, "AutoCAD.Application")
If Err.Number Then
Err.Clear()
AcadApp = CreateObject("AutoCAD.Application")
If Err.Number Then
MsgBox("不能運(yùn)行AutoCAD,請(qǐng)檢查是否安裝了AutoCAD")
Exit Sub
End If
End If
AcadApp.Visible = True '界面可視
'AcadApp.WindowState = AutoCAD.AcWindowState.acMax '界面最大化
AcadApp.WindowState = Autodesk.AutoCAD.Interop.Common.AcWindowState.acMax
AppActivate(AcadApp.Caption) '顯示AutoCAD界面
End Sub
Private Function isopen() As AutoCAD.AcadApplication
Try
dim CADapp_temp AutoCAD.AcadApplication = GetObject(, "AutoCAD.Application")
return CADapp_temp
Catch ex As Exception
Return Nothing
End Try
End Function
'調(diào)用上面的函數(shù),如果為nothing表示沒(méi)有打開(kāi),否則打開(kāi)并返回對(duì)象
如果可以的話請(qǐng)把分給我
以下是cad2007版的,引用autocad 2007 type library 和autocad/objectdbx common 17如果是04或者版本更低的只要引用autocad 2007 type library,代碼的話大同小異,思路是一樣的
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
On Error Resume Next
Dim acadapp As Autodesk.AutoCAD.Interop.AcadApplication
acadapp = GetObject(vbNullString, "autoCAD.application")
Dim acaddoc As Autodesk.AutoCAD.Interop.AcadDocument
acaddoc = acadapp.ActiveDocument
Dim Ms As Autodesk.AutoCAD.Interop.Common.AcadModelSpace
Ms = acaddoc.ModelSpace
Dim acadObjectI As Autodesk.AutoCAD.Interop.Common.AcadObject
Dim Linei As Autodesk.AutoCAD.Interop.Common.AcadLine
Dim Circlei As Autodesk.AutoCAD.Interop.Common.AcadCircle
Dim Polylinei As Autodesk.AutoCAD.Interop.Common.AcadPolyline
Dim pt As Autodesk.AutoCAD.Interop.Common.AcadPoint
For Each acadObjectI In Ms
Debug.Print(acadObjectI.ObjectName)
Select Case acadObjectI.ObjectName
Case "AcDbLine"
Linei = acadObjectI
Debug.Print("X =" Linei.StartPoint(0).ToString)
Debug.Print("Y =" Linei.StartPoint(1).ToString)
Case ""
Case ""
End Select
Next
End Sub