.NET

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

Rasterimage

156 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community