如果可以的話請把分給我
創新互聯公司是一家專注于成都網站建設、網站設計與策劃設計,安達網站建設哪家好?創新互聯公司做網站,專注于網站建設十多年,網設計領域的專業建站公司;建站業務涵蓋:安達等地區。安達做網站價格咨詢:18982081108
以下是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
你去查查書吧,書上挺詳細的,在這說不好說,你先在項目里引用。然后 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("不能運行AutoCAD,請檢查是否安裝了AutoCAD") Exit Sub End If End If AcadApp.Visible = True '界面可視
vb2010(vb.net)貌似已經沒有OLE控件
下面的代碼是用PictureBox控件顯示CAD的DWG文件
Private?Structure?BITMAPFILEHEADER
Dim?bfType?As?Short
Dim?bfSize?As?Integer
Dim?bfReserved1?As?Short
Dim?bfReserved2?As?Short
Dim?bfOffBits?As?Integer
End?Structure
Public?Function?GetDwgImage(ByVal?FileName?As?String)?As?Image
If?Not?File.Exists(FileName)?Then?Exit?Function
Dim?DwgF?As?FileStream????'文件流
Dim?PosSentinel?As?Integer??'文件描述塊的位置
Dim?br?As?BinaryReader??'讀取二進制文件
Dim?TypePreview?As?Integer?'縮略圖格式
Dim?PosBMP?As?Integer?'縮略圖位置
Dim?LenBMP?As?Integer?'縮略圖大小
Dim?biBitCount?As?Short?'縮略圖比特深度
Dim?biH?As?BITMAPFILEHEADER?'BMP文件頭,DWG文件中不包含位圖文件頭,要自行加上去
Dim?BMPInfo()?As?Byte??'包含在DWG文件中的BMP文件體
Dim?BMPF?As?New?MemoryStream??'保存位圖的內存文件流
Dim?bmpr?As?New?BinaryWriter(BMPF)?'寫二進制文件類
Dim?myImg?As?Image
Try
DwgF?=?New?FileStream(FileName,?FileMode.Open,?FileAccess.Read)????'文件流
br?=?New?BinaryReader(DwgF)
DwgF.Seek(13,?SeekOrigin.Begin)?'從第十三字節開始讀取
PosSentinel?=?br.ReadInt32?'第13到17字節指示縮略圖描述塊的位置
DwgF.Seek(PosSentinel?+?30,?SeekOrigin.Begin)?'將指針移到縮略圖描述塊的第31字節
TypePreview?=?br.ReadByte?'第31字節為縮略圖格式信息,2?為BMP格式,3為WMF格式
Select?Case?TypePreview
Case?1
Case?2,?3
PosBMP?=?br.ReadInt32?'DWG文件保存的位圖所在位置
LenBMP?=?br.ReadInt32?'位圖的大小
DwgF.Seek(PosBMP?+?14,?SeekOrigin.Begin)?'移動指針到位圖塊
biBitCount?=?br.ReadInt16?'讀取比特深度
DwgF.Seek(PosBMP,?SeekOrigin.Begin)?'從位圖塊開始處讀取全部位圖內容備用
BMPInfo?=?br.ReadBytes(LenBMP)??'不包含文件頭的位圖信息
br.Close()
DwgF.Close()
With?biH??'建立位圖文件頭
.bfType?=?H4D42
If?biBitCount??9?Then?.bfSize?=?54?+?4?*?(2?^?biBitCount)?+?LenBMP?Else?.bfSize?=?54?+?LenBMP
.bfReserved1?=?0?'保留字節
.bfReserved2?=?0?'保留字節
.bfOffBits?=?14?+?H28?+?1024?'圖像數據偏移
End?With
'以下開始寫入位圖文件頭
bmpr.Write(biH.bfType)?'文件類型
bmpr.Write(biH.bfSize)?'文件大小
bmpr.Write(biH.bfReserved1)?'0
bmpr.Write(biH.bfReserved2)?'0
bmpr.Write(biH.bfOffBits)?'圖像數據偏移
bmpr.Write(BMPInfo)?'寫入位圖
BMPF.Seek(0,?SeekOrigin.Begin)?'指針移到文件開始處
myImg?=?Image.FromStream(BMPF)?'創建位圖文件對象
Return?myImg
bmpr.Close()
BMPF.Close()
End?Select
Catch?ex?As?Exception
Return?Nothing
End?Try
End?Function
文章題目:vb.netcad控件,vbnet cad
當前URL:http://m.newbst.com/article12/hseegc.html
成都網站建設公司_創新互聯,為您提供網站設計、云服務器、服務器托管、靜態網站、網頁設計公司、定制網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯