.NET

Reply
Contributor
SoloviewSerg
Posts: 11
Registered: ‎05-19-2005
Message 1 of 13 (363 Views)

RasterImageDef

363 Views, 12 Replies
05-19-2005 05:15 AM
i have Autodesk.AutoCAD.DatabaseServices.Image in Autodesk.AutoCAD.DatabaseServices.BlockTableRecord named *ModelSpace.
How convert It to Autodesk.AutoCAD.DatabaseServices.RasterImage ?
i have Autodesk.AutoCAD.DatabaseServices.DBObject in
Autodesk.AutoCAD.DatabaseServices.DBDictionary
named "ACAD_IMAGE_DICT"
How convert It to
Autodesk.AutoCAD.DatabaseServices.RasterImageDef ?
*Albert Szilvasy
Message 2 of 13 (363 Views)

Re: RasterImageDef

05-19-2005 05:31 PM in reply to: SoloviewSerg
What version of AutoCAD are you using. I seem to remember we had a bug in
R2005 so you really had to go out of you way to manipulate raster images. We
fixed this in R2006. If you are working witth R2005 then let me know and
I'll try to dig up the workaround (I seem to remember there was one...)

Albert

wrote in message news:4850136@discussion.autodesk.com...
i have Autodesk.AutoCAD.DatabaseServices.Image in
Autodesk.AutoCAD.DatabaseServices.BlockTableRecord named *ModelSpace.
How convert It to Autodesk.AutoCAD.DatabaseServices.RasterImage ?
i have Autodesk.AutoCAD.DatabaseServices.DBObject in
Autodesk.AutoCAD.DatabaseServices.DBDictionary
named "ACAD_IMAGE_DICT"
How convert It to
Autodesk.AutoCAD.DatabaseServices.RasterImageDef ?
Contributor
SoloviewSerg
Posts: 11
Registered: ‎05-19-2005
Message 3 of 13 (363 Views)

Re: RasterImageDef

05-19-2005 10:49 PM in reply to: SoloviewSerg
For Albert Szilvasy .
Yes,I try to use R2005. I will be very grateful, if you fix my problem.
I work in VS2003EA,VB.net.
But what kind difference R2005 from R2006 ?
Thank You for answers.
*Albert Szilvasy
Message 4 of 13 (363 Views)

Re: RasterImageDef

05-19-2005 11:41 PM in reply to: SoloviewSerg
Here's some code that hopefully helps you out. There's a lot of difference
between R2005 and R2006 with regards to the .NET. We expanded the API quite
a bit.

Albert

Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime

Public Class Test
_
Public Sub Test()

Dim db As Database = HostApplicationServices.WorkingDatabase
Dim nod As DBDictionary
Dim imageDict As DBDictionary
Dim rasterImageDef As
Autodesk.AutoCAD.DatabaseServices.RasterImageDef
Dim dictEntry As System.Collections.DictionaryEntry

Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager =
db.TransactionManager
Dim trans As Autodesk.AutoCAD.DatabaseServices.Transaction =
tm.StartTransaction

Try
nod = tm.GetObject(db.NamedObjectsDictionaryId,
OpenMode.ForRead, False)
imageDict = tm.GetObject(nod.GetAt("ACAD_IMAGE_DICT"),
OpenMode.ForRead, False)

For Each dictEntry In imageDict
Dim obj As DBObject
obj = tm.GetObject(dictEntry.Value(), OpenMode.ForWrite,
False)

'check if obj is a RasterImage def the hard way:
If
obj.GetRXClass.IsDerivedFrom(RXClass.GetClass(GetType(RasterImageDef))) Then
'create a RasterImageDef wrapper
rasterImageDef =
DisposableWrapper.Create(GetType(RasterImageDef), obj.UnmanagedObject,
False)
End If

Dim imagePath As String
' see if the image path is right
imagePath = rasterImageDef.SourceFileName

If Not rasterImageDef.IsLoaded Then
' Test - Force a regen
'rasterImageDef.AssertWriteEnabled(True, True)
rasterImageDef.Load()
End If
Next
trans.Commit()
Catch
'aborts (or causes a "rollback" of) the transaction
trans.Abort()
'CommandLinePrompts.Message("Oops!!" & vbCrLf)
Finally
If (Not trans Is Nothing) Then
trans.Dispose()
End If
End Try
End Sub
End Class
wrote in message news:4851393@discussion.autodesk.com...
For Albert Szilvasy .
Yes,I try to use R2005. I will be very grateful, if you fix my problem.
I work in VS2003EA,VB.net.
But what kind difference R2005 from R2006 ?
Thank You for answers.
Contributor
SoloviewSerg
Posts: 11
Registered: ‎05-19-2005
Message 5 of 13 (363 Views)

Re: RasterImageDef

05-20-2005 01:28 AM in reply to: SoloviewSerg
I'm very glad to see your code.
It's working!!!!!!!!
Thank's for your attention.
Respectfully yours.

serg
Contributor
SoloviewSerg
Posts: 11
Registered: ‎05-19-2005
Message 6 of 13 (363 Views)

Re: RasterImageDef

05-20-2005 01:55 AM in reply to: SoloviewSerg
For Albert.
I have got Autodesk.AutoCAD.DatabaseServices.RasterImage from Autodesk.AutoCAD.DatabaseServices.Image (by your code),but can I get RasterImageDef from TransactionManager in R2005 ?

Dim rasterIm As RasterImage
If image.GetRXClass.IsDerivedFrom(RXClass.GetClass(GetType(RasterImage))) Then
'create a RasterImage wrapper
rasterIm = DisposableWrapper.Create(GetType(RasterImage), image.UnmanagedObject, False)
End If
Dim rastImDef As RasterImageDef
rastImDef = CType(tm.GetObject(rasterIm.ImageDefId, OpenMode.ForRead, True), RasterImageDef)

Once again thank you.
serg
*Albert Szilvasy
Message 7 of 13 (363 Views)

Re: RasterImageDef

05-23-2005 06:04 PM in reply to: SoloviewSerg
Have you tried going through the same trick or manually creating the wrapper
for the RasterImageDef?

Albert

wrote in message news:4851453@discussion.autodesk.com...
For Albert.
I have got Autodesk.AutoCAD.DatabaseServices.RasterImage from
Autodesk.AutoCAD.DatabaseServices.Image (by your code),but can I get
RasterImageDef from TransactionManager in R2005 ?

Dim rasterIm As RasterImage
If
image.GetRXClass.IsDerivedFrom(RXClass.GetClass(GetType(RasterImage))) Then
'create a RasterImage wrapper
rasterIm =
DisposableWrapper.Create(GetType(RasterImage), image.UnmanagedObject, False)
End If
Dim rastImDef As RasterImageDef
rastImDef = CType(tm.GetObject(rasterIm.ImageDefId,
OpenMode.ForRead, True), RasterImageDef)

Once again thank you.
serg
Contributor
SoloviewSerg
Posts: 11
Registered: ‎05-19-2005
Message 8 of 13 (363 Views)

Re: RasterImageDef

05-24-2005 07:53 AM in reply to: SoloviewSerg
I have got RasterImage through the same trick from Image ( Image from CurrentSpace), but I can't get RasterImageDef from : rasterIm.ImageDefId
rastImDef = tm.GetObject(rasterIm.ImageDefId,
OpenMode.ForRead, True)
*Albert Szilvasy
Message 9 of 13 (363 Views)

Re: RasterImageDef

05-24-2005 10:28 PM in reply to: SoloviewSerg
Ok. So once you have rasterIm.ImageDefId do this (I haven't compiled this so
please excuse any typos):

Dim obj As DBobject = tm.GetObject(rasterIm.ImageDefId, OpenMode.ForRead,
True)
If obj.GetRXClass.IsDerivedFrom(RXClass.GetClass(GetType(RasterImageDef)))
Then
'create a RasterImageDef wrapper
rasterImageDef =
DisposableWrapper.Create(GetType(RasterImageDef), obj.UnmanagedObject,
False)
End If

wrote in message news:4854580@discussion.autodesk.com...
I have got RasterImage through the same trick from Image ( Image from
CurrentSpace), but I can't get RasterImageDef from : rasterIm.ImageDefId
rastImDef = tm.GetObject(rasterIm.ImageDefId,
OpenMode.ForRead, True)
Contributor
SoloviewSerg
Posts: 11
Registered: ‎05-19-2005
Message 10 of 13 (363 Views)

Re: RasterImageDef

05-31-2005 02:18 AM in reply to: SoloviewSerg
for Albert.
Big thank's for Your halp!
But now I nave new question.
How to determine the status of RasterImageDef - "Unreferenced" ?
How to get a entity which referenced by RasterImageDef ?
I bear in mind that if entity is erased signifies that status of RasterImageDef is "Unreferenced".

serg.

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