[討論]Autocad VB.Net 練習一
AutoCAD顧問 :: 技術(發言等級:一般會員) :: :: 進階討論
第1頁(共1頁)
[討論]Autocad VB.Net 練習一
我拿影像檔(jpg) 來練 VB.Net, 一開始有點麻煩, 後來覺得功能蠻好的. 參考一下. 程式使用: 1. 將 222.jpg 放在 C:\ 2. 輸入 netload 3. 選擇 get_outline.dll 4. 輸入 mm 5. 在原點會用圓畫出字樣. 我的電腦環境 : windows 7 64 bits, Autocad 2014 64 bits, Visual Studio Express 2012
- 附件
shackle_2005 在 2016-12-12, 11:27 作了第 1 次修改
shackle_2005- 初級會員
- 文章總數 : 232
年齡 : 53
來自 : 台中
職業 : 程式設計
愛好 : 音樂
個性 : 隨和
使用年資 : 10 年
使用版本 : 2013
積分 : 3
經驗值 : 6758
威望值 : 361
注冊日期 : 2010-09-20
回復: [討論]Autocad VB.Net 練習一
Imports System
Imports System.Drawing
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Public Class Class1
_
Public Sub mm()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim myBitmap As System.Drawing.Bitmap
Dim i_count As Integer
Dim d_count As Integer
Dim radius As Double
radius = 0.005
myBitmap = New System.Drawing.Bitmap("c:\222.jpg")
' Get the color of a pixel within myBitmap.
Dim pixelColor As Color
Dim center As Point3d
For i_count = 0 To myBitmap.Width - 1
For d_count = 0 To myBitmap.Height - 1
pixelColor = myBitmap.GetPixel(i_count, d_count)
If Mid(pixelColor.Name.ToString, 1, 2) = "ff" And _
Mid(pixelColor.Name.ToString, 3, 1) = "0" Then
center = New Point3d(i_count * radius * 2, (myBitmap.Height - d_count) * radius * 2, 0)
Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim space As BlockTableRecord = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)
Dim circle As Circle = New Circle(center, Vector3d.ZAxis, radius)
space.AppendEntity(circle)
trans.AddNewlyCreatedDBObject(circle, True)
trans.Commit()
End Using
End If
Next
Next
End Sub
End Class
Imports System.Drawing
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Public Class Class1
Public Sub mm()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim myBitmap As System.Drawing.Bitmap
Dim i_count As Integer
Dim d_count As Integer
Dim radius As Double
radius = 0.005
myBitmap = New System.Drawing.Bitmap("c:\222.jpg")
' Get the color of a pixel within myBitmap.
Dim pixelColor As Color
Dim center As Point3d
For i_count = 0 To myBitmap.Width - 1
For d_count = 0 To myBitmap.Height - 1
pixelColor = myBitmap.GetPixel(i_count, d_count)
If Mid(pixelColor.Name.ToString, 1, 2) = "ff" And _
Mid(pixelColor.Name.ToString, 3, 1) = "0" Then
center = New Point3d(i_count * radius * 2, (myBitmap.Height - d_count) * radius * 2, 0)
Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim space As BlockTableRecord = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)
Dim circle As Circle = New Circle(center, Vector3d.ZAxis, radius)
space.AppendEntity(circle)
trans.AddNewlyCreatedDBObject(circle, True)
trans.Commit()
End Using
End If
Next
Next
End Sub
End Class
- 附件
shackle_2005- 初級會員
- 文章總數 : 232
年齡 : 53
來自 : 台中
職業 : 程式設計
愛好 : 音樂
個性 : 隨和
使用年資 : 10 年
使用版本 : 2013
積分 : 3
經驗值 : 6758
威望值 : 361
注冊日期 : 2010-09-20
AutoCAD顧問 :: 技術(發言等級:一般會員) :: :: 進階討論
第1頁(共1頁)
這個論壇的權限:
您 無法 在這個版面回復文章