我有一些问题,我想问一下,我不能在CAD文件中插入lilin.jpg的图片和代码
On Error Resume Next
Set ohost = GetObject("AutoCAD.Application.19") '检查AutoCAD是否已经打开
If Err <> 0 Then '没有打开
Err.Clear
Set ohost = CreateObject("AutoCAD.Application.19") '打开CAD
If Err Then
MsgBox Err.Number & ":" & Err.Description '打开失败
Exit Sub
End If
End If
Set odaApp = ohost.Application
ohost.Visible = True
Set odoc = ohost.Documents.Open(filePath)
Set acadDoc = ohost.ActiveDocument
'gr 测试
Dim insertPoint(0 To 2) As Double
Dim scalefactor As Double
Dim rotationAngle As Double
Dim imageName As String
Dim rasterObj As AcadRasterImage
imageName = "D:/Siemens/signpic/lilin.jpg" insertPoint
(0) = 5#: insertPoint(1) = 5#: insertPoint(2) = 0#
scalefactor = 1#
rotationAngle = 0
On Error Resume Next
' 在模型空间中创建光栅图像
Set rasterObj = acadDoc.ModelSpace.AddRaster(imageName, insertPoint, scalefactor, rotationAngle)
If Err.Description = "File error" Then
MsgBox imageName & " could not be found."
Exit Sub
End If
odoc.Save
odoc.Close
End Sub
我有一些问题,我想问一下,我不能在CAD文件中插入lilin.jpg的图片和代码
On Error Resume Next
Set ohost = GetObject("AutoCAD.Application.19") '检查AutoCAD是否已经打开
If Err <> 0 Then '没有打开
Err.Clear
Set ohost = CreateObject("AutoCAD.Application.19") '打开CAD
If Err Then
MsgBox Err.Number & ":" & Err.Description '打开失败
Exit Sub
End If
End If
Set odaApp = ohost.Application
ohost.Visible = True
Set odoc = ohost.Documents.Open(filePath)
Set acadDoc = ohost.ActiveDocument
'gr 测试
Dim insertPoint(0 To 2) As Double
Dim scalefactor As Double
Dim rotationAngle As Double
Dim imageName As String
Dim rasterObj As AcadRasterImage
imageName = "D:/Siemens/signpic/lilin.jpg" insertPoint
(0) = 5#: insertPoint(1) = 5#: insertPoint(2) = 0#
scalefactor = 1#
rotationAngle = 0
On Error Resume Next
' 在模型空间中创建光栅图像
Set rasterObj = acadDoc.ModelSpace.AddRaster(imageName, insertPoint, scalefactor, rotationAngle)
If Err.Description = "File error" Then
MsgBox imageName & " could not be found."
Exit Sub
End If
odoc.Save
odoc.Close
End Sub
Can't find what you're looking for? Ask the community or share your knowledge.