yue_pan_pan 2023-10-17 11:45 采纳率: 45.5%
浏览 18
已结题

teigha.net4.0 如何显示ole图片。

gpt回答请绕行。

Public Sub InsertOleObject(btr As BlockTableRecord, tr As Transaction, db As Database)
        Dim imagePath As String = Application.StartupPath + "/logo.jpg"
        ' 创建一个新的OLE2Frame对象
        Dim oleFrame1 As Ole2Frame = New Ole2Frame()
        oleFrame1.CreateFromFile(imagePath)
        ' 定义矩形的四个角点
        Dim upperLeft As Point3d = New Point3d(0, 5000, 0)
        Dim upperRight As Point3d = New Point3d(10000, 5000, 0)
        Dim lowerLeft As Point3d = New Point3d(0, 0, 0)
        Dim lowerRight As Point3d = New Point3d(10000, 0, 0)
        ' 使用四个点来创建 Rectangle3d
        Dim rect As Rectangle3d = New Rectangle3d(upperLeft, upperRight, lowerLeft, lowerRight)
        oleFrame1.Position3d = rect
        Dim translationMatrix As Matrix3d = Matrix3d.Displacement(New Vector3d(100, 0, 0))
        ' 使用矩阵变换来移动实体
        oleFrame1.TransformBy(translationMatrix)
        ' 将OLE对象添加到模型空间
        btr.AppendEntity(oleFrame1)
        tr.AddNewlyCreatedDBObject(oleFrame1, True)
    End Sub

这段代码运行没有问题。但是没有显示出来任何东西。

  • 写回答

10条回答 默认 最新

  • 呈两面包夹芝士 2023-10-17 11:49
    关注

    试试这个

    Public Sub InsertOleObject(btr As BlockTableRecord, tr As Transaction, db As Database)  
        Dim imagePath As String = Application.StartupPath + "/logo.jpg"  
        ' 创建一个新的OLE2Frame对象  
        Dim oleFrame1 As Ole2Frame = New Ole2Frame()  
        oleFrame1.CreateFromFile(imagePath)  
        ' 定义矩形的四个角点  
        Dim upperLeft As Point3d = New Point3d(0, 5000, 0)  
        Dim upperRight As Point3d = New Point3d(10000, 5000, 0)  
        Dim lowerLeft As Point3d = New Point3d(0, 0, 0)  
        Dim lowerRight As Point3d = New Point3d(10000, 0, 0)  
        ' 使用四个点来创建 Rectangle3d  
        Dim rect As Rectangle3d = New Rectangle3d(upperLeft, upperRight, lowerLeft, lowerRight)  
        oleFrame1.Position3d = rect  
        Dim translationMatrix As Matrix3d = Matrix3d.Displacement(New Vector3d(100, 0, 0))  
        ' 使用矩阵变换来移动实体  
        oleFrame1.TransformBy(translationMatrix)  
        ' 将OLE对象添加到模型空间  
        btr.AppendEntity(oleFrame1)  
        tr.AddNewlyCreatedDBObject(oleFrame1, True)  
        tr.Commit()  
        db.Regenerate()  
    End Sub
    
    
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 10月19日
  • 修改了问题 10月17日
  • 创建了问题 10月17日