.NET

Reply
New Member
marmio
Posts: 1
Registered: ‎04-28-2006
Message 1 of 1 (164 Views)

Rasterimage

164 Views, 0 Replies
04-28-2006 04:02 PM
I need to insert raster image in Map 3D 2006 by using VB.NET DLL that is loaded via NETLOAD

This is a code from my .net assembly
...
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager
Dim trans As Autodesk.AutoCAD.DatabaseServices.Transaction = tm.StartTransaction

Dim ID As ObjectId
Dim bt As BlockTable
Dim btr As BlockTableRecord
Dim msbtr As BlockTableRecord ' model space block table record

Dim RasterImgDef As New RasterImageDef
Dim RasterImg As New RasterImage
Dim ImgDict As DBDictionary
Dim ImgDictID As ObjectId
Try
'***********************************************
' definition
RasterImgDef.SourceFileName = "c:\picture\sunset.jpg"
RasterImgDef.Load()
' dictionary
ImgDictID = RasterImgDef.GetImageDictionary(db)
If ImgDictID.IsNull Then
ImgDictID = RasterImgDef.CreateImageDictionary(db)
End If
ImgDict = tm.GetObject(ImgDictID, OpenMode.ForWrite)
If Not ImgDict.Contains(NazivFajla(Putanja)) Then
ID = ImgDict.SetAt(NazivFajla(Putanja), RasterImgDef)
End If
tm.AddNewlyCreatedDBObject(RasterImgDef, True)

' image
RasterImg.ImageDefId = RasterImgDef.ObjectId
bt = tm.GetObject(db.BlockTableId, OpenMode.ForRead)

msbtr = tm.GetObject(bt.Item(msbtr.ModelSpace), OpenMode.ForWrite)
ID = msbtr.AppendEntity(RasterImg)
tm.AddNewlyCreatedDBObject(RasterImg, True)

trans.Commit()
Catch ex As Exception
trans.Abort()
MsgBox(ex.Message, MsgBoxStyle.Critical)
Finally
If (Not trans Is Nothing) Then
trans.Dispose()
End If
End Try
....

It works fine (no errors), and I can see my image, but image is marked as "unreferenced" when I open Image manager. Also image does not react to reloading or detaching.
What am I doing wrong?

Another question
How can I get all rasterimage objects that reference rasterimagedef. I can count them with getentitycount method them but I can't get them.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!