田草博客





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

邮箱:tiancao1001x126.com
日志首页 | 普通 | 电脑 | AutoCAD | VB/VB.NET | FLash | 结构 | 建筑 | 电影 | BIM | 规范
-电信用户-|-网通用户-
-博客论坛-|-软件下载-
-网站导航-|-建筑书店-
-BelovedFLash欣赏-
-来路-|-随机-|-分布-

用户登陆
用户:
密码:
 

站点日历
73 2017 - 10 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)

版权所有:田草博客
tiancao1001&126.com网友交流QQ群:11740834
Powered by L-Blog V1.08 (SE) Final© 2007-2009