AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AddRaster VB function

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
694 Views, 2 Replies

AddRaster VB function

Anonymous
Not applicable
Hi,

I have somme problems to use this VB function:

ADDRASTER

I don't know really how it works
I know there are 4 parameters:
image file name,
Insertion point,
Scalefactor,
rotation angle.

Does somebody has already used it? and can give me some information about it ?
For instance, what I have to insert as an insertion point? (I am only allowed to type 1 parameter and usually a point has X and Y coordinates).
What are the units of the parameters?
If somebody has a small program that can show me with an example how this function is working, it would be great !

Thanks

Caroline
0 Likes

AddRaster VB function

Hi,

I have somme problems to use this VB function:

ADDRASTER

I don't know really how it works
I know there are 4 parameters:
image file name,
Insertion point,
Scalefactor,
rotation angle.

Does somebody has already used it? and can give me some information about it ?
For instance, what I have to insert as an insertion point? (I am only allowed to type 1 parameter and usually a point has X and Y coordinates).
What are the units of the parameters?
If somebody has a small program that can show me with an example how this function is working, it would be great !

Thanks

Caroline
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
From the Help:

[code]
Sub Example_AddRaster()
' This example adds a raster image in model space.

' This example uses the "downtown.jpg" found in the Sample
' directory. If you do not have this image, or if it is located
' in a different directory, insert a valid path and file name
' for the imageName variable below.

Dim insertionPoint(0 To 2) As Double
Dim scalefactor As Double
Dim rotationAngle As Double
Dim imageName As String
Dim rasterObj As AcadRasterImage
imageName = "C:/AutoCAD/sample/downtown.jpg"
insertionPoint(0) = 5#: insertionPoint(1) = 5#: insertionPoint(2) = 0#
scalefactor = 1#
rotationAngle = 0

On Error Resume Next
' Creates a raster image in model space
Set rasterObj = ThisDrawing.ModelSpace.AddRaster(imageName, insertionPoint, scalefactor, rotationAngle)

If Err.Description = "File error" Then
MsgBox imageName & " could not be found."
Exit Sub
End If
End Sub
[/code]

Scott
0 Likes

From the Help:

[code]
Sub Example_AddRaster()
' This example adds a raster image in model space.

' This example uses the "downtown.jpg" found in the Sample
' directory. If you do not have this image, or if it is located
' in a different directory, insert a valid path and file name
' for the imageName variable below.

Dim insertionPoint(0 To 2) As Double
Dim scalefactor As Double
Dim rotationAngle As Double
Dim imageName As String
Dim rasterObj As AcadRasterImage
imageName = "C:/AutoCAD/sample/downtown.jpg"
insertionPoint(0) = 5#: insertionPoint(1) = 5#: insertionPoint(2) = 0#
scalefactor = 1#
rotationAngle = 0

On Error Resume Next
' Creates a raster image in model space
Set rasterObj = ThisDrawing.ModelSpace.AddRaster(imageName, insertionPoint, scalefactor, rotationAngle)

If Err.Description = "File error" Then
MsgBox imageName & " could not be found."
Exit Sub
End If
End Sub
[/code]

Scott
Message 3 of 3
1005592820
in reply to: Anonymous

1005592820
Participant
Participant

我有一些问题,我想问一下,我不能在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

A_4VH8Q~CN75M3EKU`&#125;@E9C.png


odoc.Save
odoc.Close
End Sub

0 Likes

我有一些问题,我想问一下,我不能在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

A_4VH8Q~CN75M3EKU`&#125;@E9C.png


odoc.Save
odoc.Close
End Sub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report