.NET

Reply
Active Contributor
btmsoftware
Posts: 38
Registered: ‎09-06-2007
Message 1 of 5 (184 Views)
Accepted Solution

Counting instances of an image

184 Views, 4 Replies
05-29-2012 01:45 AM

Hi there,

 

I can find which images are attached to my current drawing with the following code. However, I don't know how to find out how many times they are attached.

 

Anybody ?

 

Using tr As Transaction = db.TransactionManager.StartTransaction
	Try

		Dim nod As DBDictionary
		Dim imageDict As DBDictionary

		Console.WriteLine("Getting ACAD_IMAGE_DICT DB dictionary")
		nod = CType(tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead, False), DBDictionary)
		imageDict = CType(tr.GetObject(nod.GetAt("ACAD_IMAGE_DICT"), OpenMode.ForRead, False), DBDictionary)

		For Each dicentry As DBDictionaryEntry In imageDict
			Dim myRasterImgDef As RasterImageDef = CType(tr.GetObject(CType(dicentry.Value, ObjectId), OpenMode.ForRead), RasterImageDef)

			If myRasterImgDef.IsLoaded Then
				Console.WriteLine("Found: " & myRasterImgDef.ActiveFileName)

				' NEED TO COUNT INSTANCES HERE
								
			Else
				Console.WriteLine("Not found: " & myRasterImgDef.SourceFileName)
			End If
		Next

		tr.Commit()

	Catch ex As Exception
		System.Windows.Forms.MessageBox.Show(ex.ToString, "Configurator", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Stop)
	End Try

End Using

 Thanx in advance

Hi

 

Can you try DevBlog solution "Identifying number times a Raster Image is used in a drawing"

http://adndevblog.typepad.com/autocad/2012/05/identifying-number-times-a-raster-images-is-used-in-a-drawing.html?

 

Thanks

Virupaksha aithal

Autodesk Devloper Network

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 2 of 5 (177 Views)

Re: Counting instances of an image

05-29-2012 02:37 AM in reply to: btmsoftware
You need to search for raster reference entities of type RasterImage. There are two options I know for this, depending on your requirements: 1. Use Editor.SelectAll(), passing in a SelectionFilter with the appropriate dxf code. This is easiest but will only work in the current layout. Note: You might also need to zoom extents for this to work, i can't remember if you need to. 2. Iterate your block table records looking for RasterImage entities, using a counter. Advantage with this approach is that you can iterate your model space as well as all of your paper space block table records - i.e. you will get all of them.
Active Contributor
btmsoftware
Posts: 38
Registered: ‎09-06-2007
Message 3 of 5 (170 Views)

Re: Counting instances of an image

05-29-2012 03:11 AM in reply to: Artvegas

Will give option 2 a shot, seems the most appropriate indeed.

 

If you happen to have an example for this iteration ,great, if not, I'll figure it out by myself ;-)

 

ADN Support Specialist
Virupaksha.aithal
Posts: 97
Registered: ‎06-15-2011
Message 4 of 5 (161 Views)

Re: Counting instances of an image

05-29-2012 04:41 AM in reply to: btmsoftware

Hi

 

Can you try DevBlog solution "Identifying number times a Raster Image is used in a drawing"

http://adndevblog.typepad.com/autocad/2012/05/identifying-number-times-a-raster-images-is-used-in-a-...?

 

Thanks

Virupaksha aithal

Autodesk Devloper Network



Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

Active Contributor
btmsoftware
Posts: 38
Registered: ‎09-06-2007
Message 5 of 5 (152 Views)

Re: Counting instances of an image

05-29-2012 05:00 AM in reply to: Virupaksha.aithal

Exactly what I needed, thanx a lot

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 or visit the Installation and Licensing Forum to get help installing your software.