.NET

Reply
Valued Contributor
celsoven
Posts: 80
Registered: ‎06-25-2009
Message 1 of 9 (1,505 Views)

Create a thumbnail from a block inside AutoCAD

1505 Views, 8 Replies
09-11-2012 12:33 PM

Hello.

 

I hope someone could help me with this.

 

I'm developing a tool similar to Insert command.

 

All I need is to get the thumbnail (image preview) from blocks in my drawing with vb.net application.

 

I'm Using VS2010, and API.COM to develop this.

 

I found how to do this with an external dwg file, but in this case i want to show the thumbnail from blocks in a drawing opened.

 

Thanks in advance.

 

 

Valued Mentor
AubelecBE
Posts: 372
Registered: ‎01-27-2010
Message 2 of 9 (1,469 Views)

Re: Create a thumbnail from a block inside AutoCAD

09-12-2012 03:23 AM in reply to: celsoven

You can use the command : BLOCKICON

 

it generate the preview of each BlockDef in your dwg.

 

Valued Contributor
celsoven
Posts: 80
Registered: ‎06-25-2009
Message 3 of 9 (1,449 Views)

Re: Create a thumbnail from a block inside AutoCAD

09-12-2012 01:03 PM in reply to: AubelecBE

Thanks for reply AubelecBE

 

I didn't know that command, but that command just updates the thumbnails blocks, but I want to show the thumbnail in a pictureBox.

 

I could do it from a file.

 

For example suppose you have a dwg file calls  "c:\work\01.dwg"

 

I have a function call  GetThumbnail  it creates a bmp Object and I can use that bmp to shows in a picturebox 

 

 Dim bmp AsBitmap

bmp = dibujo.GetThumbnail("c:\work\01.dwg", True)

pictureBox.Image = bmp

 

Now I want to do it from the same dwg file that I have opened.

 

Any suggestions?

Valued Mentor
jeff
Posts: 322
Registered: ‎05-12-2009
Message 4 of 9 (1,441 Views)

Re: Create a thumbnail from a block inside AutoCAD

09-12-2012 01:59 PM in reply to: celsoven

If you mean a BlockTableRecord(BlockDefinition) then use BlockTableRecord.PreviewIcon property.

 

As Aubelec mentioned you might still need to use BLOCKICON if BlockTableRecord.PreviewIcon is null or needs to be updated

You can also find your answers @ TheSwamp
Distinguished Contributor
fxcastil
Posts: 404
Registered: ‎11-11-2002
Message 5 of 9 (1,437 Views)

Re: Create a thumbnail from a block inside AutoCAD

09-12-2012 02:29 PM in reply to: celsoven

Imports Autodesk.AutoCAD.DatabaseServices.BlockTableRecord

 

The BlockTableRecord looks like it has the "GetThumbnailimage" property you need, if you look an an example of how to iterate the block attriibutes property, and change it to get the thumbnail image for each block that should get you started in the right direction.   You would need to define a bitmap for each block and then display the bitmap in a userform using a standard Visual Studio PictureBox control.

 

BlockTableRecord.PreviewIcon.GetThumbnailImage

 

**********************************

Found the link below which looks even easier

 

http://www.theswamp.org/index.php?topic=32746.msg382467#msg382467

 

Valued Contributor
celsoven
Posts: 80
Registered: ‎06-25-2009
Message 6 of 9 (1,393 Views)

Re: Create a thumbnail from a block inside AutoCAD

09-13-2012 03:59 PM in reply to: fxcastil

Hello every body.

 

I've been searching how to use BlockTableRecord, but I haven't found more information, but I think it is used with API.NET, and I'm just use API.COM because I have learned from VBA and it was easier than API.NET for me.

 

Is there a way to create thumbnails using API.COM???

 

I hope his help.

 

Thanks in advance.

Valued Contributor
celsoven
Posts: 80
Registered: ‎06-25-2009
Message 7 of 9 (1,392 Views)

Re: Create a thumbnail from a block inside AutoCAD

09-13-2012 04:17 PM in reply to: celsoven

Hello I want to share the way that momentarily I have solved how to get the thumbnail

 

1. I fill the combobox with all blocks in the drawing

2. When I select the block I make a dwgFile using Wblock

thisdrawing.SendCommand("-wblock c:/work/01.dwg" & Chr(13) & nomBloque & Chr(13))

3. Call a function that makes a thumbnail and I keep it and show it in the pictureBox.

 

Inconvenience.

 

Each time that I select a block from the comboBox I have to create a wblock and replace the file.

Is a little slow.

 

I hope their comments and help

 

Thanks

Distinguished Contributor
fxcastil
Posts: 404
Registered: ‎11-11-2002
Message 8 of 9 (1,365 Views)

Re: Create a thumbnail from a block inside AutoCAD

09-14-2012 01:21 PM in reply to: celsoven

If you are using API.com try using dwgThumbnail.ocx , the preview looks better than a picture box.

 

Remane the file with an .OCX extension

 

Search   dwgThumbnail  in the VBA section for more info.

 

 

 

New Member
56545454
Posts: 2
Registered: ‎04-10-2013
Message 9 of 9 (981 Views)

Re: Create a thumbnail from a block inside AutoCAD

04-10-2013 10:42 PM in reply to: celsoven
  • this image programme creat high quality thumnail into their VB.NET application. i hope it helps.

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