.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rasterimage

0 REPLIES 0
Reply
Message 1 of 1
marmio
271 Views, 0 Replies

Rasterimage

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.
0 REPLIES 0

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost