VB.Net读取AutoCAD图纸如果可以的话请把分给我
以下是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
在VB环境下引用CAD材质库,原本的Thisdrawing提示未声明,应该怎么搞Private Sub Command1_Click()
'首先引用 acad 2009 Object Library类型库
Dim myAcadApp As AutoCAD.AcadApplication, activeDoc As AutoCAD.AcadDocument, acMS As AutoCAD.AcadModelSpace
On Error Resume Next
Set myAcadApp = GetObject(, "Autocad.Application") '检查AutoCAD是否已经打开
If Err0 Then '没有打开
Err.Clear
Set myAcadApp = CreateObject("Autocad.Application") '打开CAD
If Err Then
MsgBox Err.Number":"Err.Description '打开失败
Exit Sub
End If
End If
On Error GoTo prcERR
myAcadApp.Visible = True '显示CAD
Set activeDoc = myAcadApp.ActiveDocument
Dim startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double
Dim LineObj As AcadLine'如果画图时出错,改为Dim LineObj As Object
startPoint(0) = 0: startPoint(1) = 0: startPoint(2) = 0
endPoint(0) = 30: endPoint(1) = 20: endPoint(2) = 0
Set LineObj = activeDoc.ModelSpace.AddLine(startPoint, endPoint) '画线
prcExit:
Set activeDoc = Nothing
Set myAcadApp = Nothing
Exit Sub
prcERR:
MsgBox Err.Number":"Err.Description, vbCritical, "错误"
Resume prcExit
End Sub
如何使用vb.net调用cad进行绘图你去查查书吧,书上挺详细的,在这说不好说 , 你先在项目里引用 。然后 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 '界面可视
vb.net 如何引用自定义类库在项目A里添加引用 , 在“添加引用”对话框里找到项目B就可以了 。也可以先把项目B生成dll文件,然后在项目A中添加对这个dll文件的引用 。
VS2010中用VB.NET编程添加CAD引用出错!坐等?。?/h2>应用程序启动了没
【VB.net中cad类库 vbnet class】dim acadApp As AcadApplication
acadApp = CType(CreateObject("AutoCAD.Application.18"), AcadApplication)
acadApp.Visible = True
启动了CAD才能添加文件,其中18对应的是cad2010,版本不同不一样 。
如何用vb.net编程在cad图形中插入dwg图块?Dim ppr As PromptPointResult = ed.GetPoint("请选择插入点:")
Dim pt As Point3d = ppr.Value
utility.WriteToEditor(pt.ToString())
Dim pidBlock As New PIDBlock()
'自己定义的图块类,保存图块的路径和名称
pidBlock.Name = "sample"
pidBlock.Path = blockPath"b_sample.dwg"
Using blkDb As New Database(False, True)
'read drawing
blkDb.ReadDwgFile(pidBlock.Path, System.IO.FileShare.Read, True, Nothing)
blkDb.CloseInput(True)
Using docLock As DocumentLock = doc.LockDocument()
'多文档要先这样 , 否则报至命错误
Using t As Transaction = doc.TransactionManager.StartTransaction()
'insert it as a new block
Dim idBTR As ObjectId = doc.Database.Insert(pidBlock.Name, blkDb, False)
'create a ref to the block
Dim bt As BlockTable = DirectCast(t.GetObject(doc.Database.BlockTableId, OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = DirectCast(t.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
Using bref As New BlockReference(pt, idBTR)
btr.AppendEntity(bref)
t.AddNewlyCreatedDBObject(bref, True)
End Using
t.Commit()
End Using
End Using
End Using
VB.net中cad类库的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbnet class、VB.net中cad类库的信息别忘了在本站进行查找喔 。
推荐阅读
- 钉钉电脑直播怎么回复评论,电脑版钉钉直播怎么评论
- 小程序吸奶器安装视频讲解,吸奶器怎么装视频
- 1060显卡怎么插,1060显卡借口
- oracle数据库去重复,oracle数据库去重复数据
- go语言编辑环境 go语言环境配置
- 包含cjquerypostjson的词条
- ps5游戏机手柄射击游戏,ps5玩射击游戏手柄的感觉
- erp管理系统如何制单,erp系统怎么做表格
- linux中断程序命令,linux 中断