Block thumbnail Icon

Block thumbnail Icon

Anonymous
Not applicable
4,704 Views
21 Replies
Message 1 of 22

Block thumbnail Icon

Anonymous
Not applicable
IS there anyone who can give me some addvice about how to create a block thumbnail icon by c# code. I want to create a block by code and preview the block by BlockThumbnailHelper.GetBlockThumbanail(objcetid). Now , I have created the block, but I can't get the block thumbnail. If anyone has an answer or a hint it would be greatly appreciated.
0 Likes
4,705 Views
21 Replies
Replies (21)
Message 2 of 22

Anonymous
Not applicable
I have seen the similar question in the Discussion Groups. It is http://discussion.autodesk.com/forums/thread.jspa?essageID=5002238叾, but the code can't be loaded. Who can give me some hints? Thanks.
0 Likes
Message 3 of 22

Anonymous
Not applicable
Now,I know the CAD command "BLOCKICON". It can create the block icon. My codes are as follows:
ResultBuffer rb = new ResultBuffer();
rb.Add(new TypedValue(5005, "_BLOCKICON"));
rb.Add(new TypedValue(5005,"")); acedCmd(rb.UnmanagedObject), rb.Dispose();

I would like to use the specific block name as the second parameter,who knows how to write it?
Thanks!
0 Likes
Message 4 of 22

Anonymous
Not applicable
I found this using the search function provided:

http://discussion.autodesk.com/forums/thread.jspa?messageID=5005109張


Here's another thread with some info:

http://discussion.autodesk.com/forums/thread.jspa?messageID=5314144ᙠ



Bill
0 Likes
Message 5 of 22

Anonymous
Not applicable
Thank you,Bill. I have seen the first website you give,but the codes can not be loaded.The second site has little revelance to my question. I want to create a block preview,not a dwg file.
0 Likes
Message 6 of 22

Anonymous
Not applicable
> I have seen the first website you give,but the codes can not be loaded.

What are you having trouble with?

Did you do what it said in the .cs file?

To use the sample:
//
// 1. Create a new C# solution (a class
// library).
//
// 2. Add references to these files:
//
// acmgd.dll
// acdbmgd.dll
// AcMgdInternal.dll
//
// Note that AcMgdInternal.dll is located in
// the same folder as the other two dlls.
//
// 3. Add this form to the project and
// build it.
//
// 4. Load the assembly with NETLOAD and
// issue the BLOCKICONFORM command.
//
// Note that you must have blocks in
// the current drawing in order to see
// their icons.

also make sure you have all your resources added to the solution:

System.Drawing
System.Windows.Forms

You didn't tell us anything about what version of Visual Studio you are using or what version of AutoCAD.
>Tony Tanzillo wrote:
>That code was for older releases where the PreviewIcon
>property of the BlockTableRecord was not implemented yet.

>In 2009 it is, so you don't need that workaround any longer.



Works fine here: See Attached

Bill
0 Likes
Message 7 of 22

Anonymous
Not applicable
Thanks again,Bill.The BlockIcon.png image shows what I want to realize. My development environment is VS 2005( C# )+AutoCAD 2007. The problem is that I can not see the code in the web you gave and I do not know the content of the .cs file.But how do you see it? I am confused. In addition, the block is created by code and it has't the preview. Edited by: habbit on Apr 8, 2009 11:54 AM
0 Likes
Message 8 of 22

Anonymous
Not applicable
I just click on the link that Tony posted and it asks me if I want to save the file or run it.

http://www.caddzone.com/BlockIconSample.zip

Bill
0 Likes
Message 9 of 22

Anonymous
Not applicable
Hi,Bill.I am sorry to bother you again for the same question. I can not download the code yet. It's said that "it can not find the resource". Could you show me the code? Thank you.
0 Likes
Message 10 of 22

Anonymous
Not applicable
Hi,Bill.I am sorry to bother you again for the same question. I can not download the code yet. It's said that "it can not find the resource". Could you show me the code? Thank you.
0 Likes
Message 11 of 22

Anonymous
Not applicable
I'm not sure why you can't download it, I had no problem using
the link Bill posted.

The file is attached.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message news:6159158@discussion.autodesk.com...
Hi,Bill.I am sorry to bother you again for the same question. I can not
download the code yet. It's said that "it can not find the resource". Could
you show me the code? Thank you.
0 Likes
Message 12 of 22

Anonymous
Not applicable
Bill, I think you misunderstood what I said.I have known the way how to display the block preview. My problem is that the block is created by code and it has not preview . I just want to create block icon by code. I know the command BLOCKICON can work. But i don't want to use the command. Could you give me some hints?
0 Likes
Message 13 of 22

Anonymous
Not applicable
>I just want to create block icon by code.

Oh, I did misunderstand you.

I don't know how to do what you are asking.
I thought the icon was created automatically when you make the block.

Sorry.

Bill
0 Likes
Message 14 of 22

Anonymous
Not applicable
Very interesting.

I just created a Block in a simple C# method.

If I use the built in AutoCAD command "Insert",
the icon shows up in the insert dialog box.

But when I use Tonys "BLOCKICONFORM"
it does not show up in that for some reason.

Anyone else know what's up?

Bill
0 Likes
Message 15 of 22

Anonymous
Not applicable
I forgot to attach the code:
0 Likes
Message 16 of 22

Anonymous
Not applicable
habbit,

I think the problem lies in the BlockIconForm method and not the blockrecord that you've created.

I have some drawings that display the blocks fine,
then have others that will not display using the BlockIconForm that Tony posted.

I've attached a png of a drawing that I inserted several blocks into and yet the BlockIconForm does not display them.

I really don't know what's wrong.

Bill
0 Likes
Message 17 of 22

Anonymous
Not applicable
The sample only displays the icons of blocks that have icons,
it does not generate the icons. The icons are generated by
AutoCAD when you define a block or use the BLOCKICON
command.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message news:6159915@discussion.autodesk.com...
habbit, I think the problem lies in the BlockIconForm method and not the
blockrecord that you've created. I have some drawings that display the
blocks fine, then have others that will not display using the BlockIconForm
that Tony posted. I've attached a png of a drawing that I inserted several
blocks into and yet the BlockIconForm does not display them. I really don't
know what's wrong. Bill
0 Likes
Message 18 of 22

Anonymous
Not applicable
I am confused too. I just konw the block icon are not created automaticly when creating the block.

[DllImport( "acad.exe", CallingConvention = CallingConvention.Cdecl,EntryPoint = "?acedGenerateThumbnailBitmap@@YAPAUtagABITMAPINFO@@XZ" )]
private static extern IntPtr acedGenerateThumbnailBitmap();

IntPtr bmi = acedGenerateThumbnailBitmap();
Bitmap blockThumbnail=null;
if( bmi != IntPtr.Zero )
{
Bitmap bm = Marshaler.BitmapInfoToBitmap( bmi );
blockThumbnail = (System.Drawing.Bitmap)bm.Clone();
bm.Dispose();
}
I find the codes above, who can tell me why it can not generate the block icon? Edited by: habbit on Apr 11, 2009 9:12 AM
0 Likes
Message 19 of 22

Anonymous
Not applicable
Tony,

I ran the BLOCKICON command on these.

Just created this drawing to test.

Other drawings I have work fine.

I am using R2006 VS2005 Express. Edited by: BillZndl on Apr 13, 2009 5:37 AM
0 Likes
Message 20 of 22

Anonymous
Not applicable
I think I have found the problem.
It is a BLOCKICON command issue.

>From the help files:
>Enter block names *: Specify block names, or press ENTER to update all blocks

Okay, on some of my drawings, I can hit enter at this prompt,
and it will update all the blocks in the drawing,

The problem appears to be the imbedded block with attributes "TAG".

The BLOCKICON command has no effect on this particular block.
I can insert the "TAG" block individually and run the command on it with no results.
It does no give an error, it just will not create an icon for the "TAG" block when done individually or in the batch version.
It will make an icon for block 88763, that has the "TAG" block embedded into it and display fine,
but it must crash the BLOCKICON command when doing a "batch" of blocks and so does not update any blocks in the drawing.

As soon as I purge "TAG" from the drawing, I can use BLOCKICON -Enter and it will update all other blocks in the drawing.

*Edit: Yup, the drawings that I thought were updated were only updating until they hit the "TAG" block.

Bill

Edited by: BillZndl on Apr 13, 2009 10:29 AM Edited by: BillZndl on Apr 13, 2009 10:40 AM
0 Likes