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

RasterImageDef

12 REPLIES 12
Reply
Message 1 of 13
SoloviewSerg
1283 Views, 12 Replies

RasterImageDef

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 ?
12 REPLIES 12
Message 2 of 13
Anonymous
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 ?
Message 3 of 13
SoloviewSerg
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.
Message 4 of 13
Anonymous
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.
Message 5 of 13
SoloviewSerg
in reply to: SoloviewSerg

I'm very glad to see your code.
It's working!!!!!!!!
Thank's for your attention.
Respectfully yours.

serg
Message 6 of 13
SoloviewSerg
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
Message 7 of 13
Anonymous
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
Message 8 of 13
SoloviewSerg
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)
Message 9 of 13
Anonymous
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)
Message 10 of 13
SoloviewSerg
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.
Message 11 of 13

can you please suggest how to create system.image from autoCAD 2006 object image ... so that i will be able to use it on the user form.

thanks and regards,
namrata
Message 12 of 13
SoloviewSerg
in reply to: SoloviewSerg

Simply solution...
You can use DwgThumbnail.ocx Control on the user form.

serg.
Message 13 of 13

thanks i'll try it out
regards,
namrata

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