田草博客

互联网田草博客


网友交流QQ群:11740834 需注明申请加入原因

微信 公众号:ByCAD

邮箱:tiancao1001x126.com
ByCAD,微信公众号
首页 | 普通 | 电脑 | AutoCAD | VB/VB.NET | FLash | 结构 | 建筑 | 电影 | BIM | 规范 | 软件 | ID
-随机-|-分布-
-博客论坛-|-﨣﨤﨧﨨-
-网站导航-|-规范下载-
-BelovedFLash欣赏-

用户登陆
用户:
密码:
 

站点日历
73 2024 - 12 48
1234567
891011121314
15161718192021
22232425262728
293031


站点统计

最新评论



AutoCAD2014"可执行文件超出指定的受信任的位置"解决办法 U 命令已禁用。使用 UNDO 命令将其打开
未知 请教 ,能通过.net 将剪切板中的BMP图像直接以OLE方式插入CAD吗   [ 日期:2016-03-28 ]   [ 来自:本站原创 ]  HTML
请教 ,能通过.net 将剪切板中的BMP图像直接以OLE方式插入CAD吗

ThisDrawing.ModelSpace.AddRaster(ImageFileName, InsertPoint, ScaleFactor, RotAngle)

http://bbs.xdcad.net/thread-709228-1-1.html

[本日志由 tiancao1001 于 2017-07-04 06:44 PM 编辑]


引用这个评论 tiancao1001 于 2017-07-04 06:44 PM 发表评论: 
Private Sub insertimage(fname As String, bname As String, pt As Point3d, rot As Double, xx As Double, yy As Double)
    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument()
    Dim doc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
    Using db As Database = doc.Database
        Using tm As Transaction = db.TransactionManager.StartTransaction()
            Try
                Dim imageDictID As ObjectId = RasterImageDef.GetImageDictionary(db)
                If imageDictID.OldId = 0 Then
                    imageDictID = RasterImageDef.CreateImageDictionary(db)
                End If
                Dim rasterImageDef__1 As New RasterImageDef()
                Dim imageDict As DBDictionary = CType(tm.GetObject(imageDictID, OpenMode.ForWrite), DBDictionary)
                Dim rasterImageDefID As ObjectId
                If imageDict.Contains(bname) Then
                    rasterImageDefID = imageDict.GetAt(bname)
                    rasterImageDef__1 = CType(tm.GetObject(rasterImageDefID, OpenMode.ForWrite), RasterImageDef)
                Else
                    rasterImageDefID = imageDict.SetAt(bname, rasterImageDef__1)
                    rasterImageDef__1.SourceFileName = fname
                    rasterImageDef__1.Load()
                    rasterImageDef__1.ImageModified = True
                    rasterImageDef__1.ResolutionUnits = Unit.Millimeter
                    tm.AddNewlyCreatedDBObject(rasterImageDef__1, True)
                End If
                Dim rasterImage As New RasterImage()
                rasterImage.ImageDefId = rasterImageDef__1.ObjectId
                rasterImage.Orientation = New CoordinateSystem3d(pt, New Vector3d(xx, 0, 0), New Vector3d(0, yy, 0))
                rasterImage.Rotation = (rot * pi) / 180
                Dim bt As BlockTable = CType(tm.GetObject(doc.Database.BlockTableId, OpenMode.ForRead, False), BlockTable)
                Dim btr As BlockTableRecord = CType(tm.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False), BlockTableRecord)
                btr.AppendEntity(rasterImage)
                tm.AddNewlyCreatedDBObject(rasterImage, True)
                tm.Commit()
                tm.Dispose()
            Catch e As System.Exception
                System.Windows.Forms.MessageBox.Show(e.ToString())
            End Try
        End Using
    End Using
End Sub


引用这个评论 tiancao1001 于 2017-07-04 06:34 PM 发表评论: 
ThisDrawing.ModelSpace.AddRaster(ImageFileName, InsertPoint, ScaleFactor, RotAngle)

Tiancao Blog All Rights Reserved 田草博客 版权所有
Copyright ©