Hi,
Is there any piece of logic in this, using AutoCAD 2007 and VB 2005 :
I programmaticaly create a block definition containing a rasterImageDef.
When I programmatically create a block reference, the rasterimage is viewable, drawn, in the model object.
But when I open the picture manager (or external references manager) the .jpg file remains unreferenced.
I would like to know more about the reference manager, concerning pictures, because I haven't found anything about this in the 7 API training Labs.
Here are some pieces of my code
'##########################################
Dim RasterImgDefID As ObjectId = ObjectId.Null
' PICTURE
Dim RasterImgDef As RasterImageDef = New RasterImageDef()
Dim RasterImg As RasterImage = New RasterImage()
Dim ImgDict As DBDictionary
Dim ImgDictID As ObjectId
' definition
With RasterImgDef
.SourceFileName = T_ApplicationParams.logo_cv_path
End With
'Dictionary
ImgDictID = RasterImageDef.GetImageDictionary(db)
If (ImgDictID.IsNull) Then
ImgDictID = RasterImageDef.CreateImageDictionary(db)
End If
ImgDict = trans.GetObject(ImgDictID, OpenMode.ForWrite, False)
If (Not ImgDict.Contains(T_AcadDatabaseParams.dict_Logo_CV_name)) Then
ImgDict.SetAt(T_AcadDatabaseParams.dict_Logo_CV_name, RasterImgDef)
End If
'def
'Image
With RasterImgDef
.Load()
.OpenImage()
.UpdateEntities()
End With
With RasterImg
.ImageDefId = RasterImgDef.ObjectId
.LayerId = layerId
.Visible = True
End With
Dim newBtr As BlockTableRecord = New BlockTableRecord()
newBtr.AppendEntity(RasterImg)
trans.AddNewlyCreatedDBObject(newBtr, True)
trans.AddNewlyCreatedDBObject(RasterImgDef, True)
trans.AddNewlyCreatedDBObject(RasterImg, True)
'After inserting the picture, I modify it
With RasterImg
Dim origin As Point3d = New Point3d( _
insPoint_LogoCV_min.X, _
insPoint_LogoCV_min.Y, _
0 _
)
Dim vectx As Vector3d = New Vector3d(insPoint_LogoCV_max.X - insPoint_LogoCV_min.X, 0, 0)
Dim vecty As Vector3d = New Vector3d(0, insPoint_LogoCV_max.Y - insPoint_LogoCV_min.Y, 0)
.Orientation = New CoordinateSystem3d(origin, vectx, vecty)
.ImageDefId = RasterImgDef.ObjectId
RasterImgDef.Load()
End With
'##########################################
I hope this will be enough to understand what' happening...
Thank you by advance.