Generate preview

Generate preview

Anonymous
Not applicable
1,295 Views
11 Replies
Message 1 of 12

Generate preview

Anonymous
Not applicable
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
1,296 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable
Hello Alex,

I don't know the answer. But I would try to

- save the database (at first with database->saveAs, if not work: second with Doc->Save)

- load the database

and then (in the hope, acad has created the thumbnail) try to access to the thumbnail.

Please see also the acad help:

Note These APIs are meant primarily for ObjectDBX developers. Preview thumbnail behavior reflect what the host application must do
to generate a preview.

For ObjectARX developers AutoCAD is taking care of all preview thumbnail generation. ObjectARX users should leave these APIs alone,
and allow AutoCAD behaviors to prevail.

doc snyder


"alex" schrieb im Newsbeitrag news:5146780@discussion.autodesk.com...
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
Message 3 of 12

Anonymous
Not applicable
Hello doc snyder

From the docs:

Acad::ErrorStatus AcDbDatabase::saveAs(const char* fileName);
...
If the database executing the saveAs() function is not the current database
in the AutoCAD editor, then the thumbnail preview image is NOT saved to
fileName.

I don't need the thumbnail, I just want the db to be saved with a thumbnail,
for the next time someone opens it.

alex

"doc snyder" wrote in message
news:5147232@discussion.autodesk.com...
Hello Alex,

I don't know the answer. But I would try to

- save the database (at first with database->saveAs, if not work: second
with Doc->Save)

- load the database

and then (in the hope, acad has created the thumbnail) try to access to the
thumbnail.

Please see also the acad help:

Note These APIs are meant primarily for ObjectDBX developers. Preview
thumbnail behavior reflect what the host application must do
to generate a preview.

For ObjectARX developers AutoCAD is taking care of all preview thumbnail
generation. ObjectARX users should leave these APIs alone,
and allow AutoCAD behaviors to prevail.

doc snyder


"alex" schrieb im Newsbeitrag
news:5146780@discussion.autodesk.com...
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
Message 4 of 12

Anonymous
Not applicable
How is it failing?

wblock() won't create a thumbnail in the database it is writing to, so
pNewDB->thumbnailBitmap() should return NULL.

"alex" wrote in message
news:5146780@discussion.autodesk.com...
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
Message 5 of 12

Anonymous
Not applicable
Art:
It indeed returns NULL.
I am aware of the fact that wblock() doesn't create thumbnails, i'm just
looking for a way around it.
thanks

alex


"Art Cooney" wrote in message
news:5147493@discussion.autodesk.com...
How is it failing?

wblock() won't create a thumbnail in the database it is writing to, so
pNewDB->thumbnailBitmap() should return NULL.

"alex" wrote in message
news:5146780@discussion.autodesk.com...
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
Message 6 of 12

Anonymous
Not applicable
If you're aware that it returns NULL, then what do you mean by it "fails"?

There isn't any way to get wblock to create a thumbnail. The thumbnail is
generated by our graphics system and requires that the drawing be loaded in
the AutoCAD editor. The only way to get AutoCAD to put a thumbnail in the
drawing created by the wblock would be to open that drawing in the AutoCAD
editor and then save it.

"alex" wrote in message
news:5148244@discussion.autodesk.com...
Art:
It indeed returns NULL.
I am aware of the fact that wblock() doesn't create thumbnails, i'm just
looking for a way around it.
thanks

alex


"Art Cooney" wrote in message
news:5147493@discussion.autodesk.com...
How is it failing?

wblock() won't create a thumbnail in the database it is writing to, so
pNewDB->thumbnailBitmap() should return NULL.

"alex" wrote in message
news:5146780@discussion.autodesk.com...
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
Message 7 of 12

Anonymous
Not applicable
The logical conclusion for me is
not create a database before wblock but
let your function do all what the user makes with the drawing...
- to create a new document
- wblock the wished entities from source document
- set document to current (or active?)
- zoom (all or limits), optionally shade the dwg
- and save the dwg temporary

But the programmer not wish a mdi child, which popups in the meantime.
Here ends my hope to find a nice (acceptable) solution.

doc snyder

"Art Cooney" schrieb im Newsbeitrag news:5148272@discussion.autodesk.com...
If you're aware that it returns NULL, then what do you mean by it "fails"?

There isn't any way to get wblock to create a thumbnail. The thumbnail is
generated by our graphics system and requires that the drawing be loaded in
the AutoCAD editor. The only way to get AutoCAD to put a thumbnail in the
drawing created by the wblock would be to open that drawing in the AutoCAD
editor and then save it.

"alex" wrote in message
news:5148244@discussion.autodesk.com...
Art:
It indeed returns NULL.
I am aware of the fact that wblock() doesn't create thumbnails, i'm just
looking for a way around it.
thanks

alex


"Art Cooney" wrote in message
news:5147493@discussion.autodesk.com...
How is it failing?

wblock() won't create a thumbnail in the database it is writing to, so
pNewDB->thumbnailBitmap() should return NULL.

"alex" wrote in message
news:5146780@discussion.autodesk.com...
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
Message 8 of 12

Anonymous
Not applicable
typedef Acad::ErrorStatus
(*acdbMakeDrawingPreviewPtr)
(AcDbDatabase* pDb, bool bUnused);

Acad::ErrorStatus MakeThumbnail(AcDbDatabase* pDb)
{
static acdbMakeDrawingPreviewPtr pFunc = NULL;
if( pFunc == NULL )
{
HMODULE hLib = GetArxModuleHandle("AcBlock.arx");
if( hLib == NULL )
return Acad::eInvalidInput;
void* pv = ::GetProcAddress(hLib,
"acdbMakeDrawingPreview");
if( pv == NULL )
return Acad::eInvalidInput;
pFunc = (acdbMakeDrawingPreviewPtr) pv;
}
if( pDb == NULL )
return Acad::eInvalidInput;
return (*pFunc)(pDb, false);
}

// moduleName (filename.arx) must be on PATH.

HMODULE GetArxModuleHandle(const char* moduleName)
{
HMODULE hLib = ::GetModuleHandle(moduleName);
if( hLib == NULL )
{
acrxLoadModule(moduleName, false, false);
hLib = ::GetModuleHandle(moduleName);
}
return hLib;
}


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"alex" wrote in message news:5148244@discussion.autodesk.com...
Art:
It indeed returns NULL.
I am aware of the fact that wblock() doesn't create thumbnails, i'm just
looking for a way around it.
thanks

alex


"Art Cooney" wrote in message
news:5147493@discussion.autodesk.com...
How is it failing?

wblock() won't create a thumbnail in the database it is writing to, so
pNewDB->thumbnailBitmap() should return NULL.

"alex" wrote in message
news:5146780@discussion.autodesk.com...
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
Message 9 of 12

Anonymous
Not applicable
Art:
I just meant it fails for me. I didn't understand it works just for the
current db.
Do you have any comment to Tony's post of today?

Thanks,

alex

"Art Cooney" wrote in message
news:5148272@discussion.autodesk.com...
If you're aware that it returns NULL, then what do you mean by it "fails"?

There isn't any way to get wblock to create a thumbnail. The thumbnail is
generated by our graphics system and requires that the drawing be loaded in
the AutoCAD editor. The only way to get AutoCAD to put a thumbnail in the
drawing created by the wblock would be to open that drawing in the AutoCAD
editor and then save it.

"alex" wrote in message
news:5148244@discussion.autodesk.com...
Art:
It indeed returns NULL.
I am aware of the fact that wblock() doesn't create thumbnails, i'm just
looking for a way around it.
thanks

alex


"Art Cooney" wrote in message
news:5147493@discussion.autodesk.com...
How is it failing?

wblock() won't create a thumbnail in the database it is writing to, so
pNewDB->thumbnailBitmap() should return NULL.

"alex" wrote in message
news:5146780@discussion.autodesk.com...
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
Message 10 of 12

Anonymous
Not applicable
Tony:

Just what i was looking for.
If I understand you right, it's a (undocumented?) function exported by
AcBlock.arx
I just tried it on a ACAD2000, works OK. It looks just like what wblock
command does - thumbnailwise, including 'low quality' thumbnail.
It seems the GS has to 'see' it on the screen to do it right.
Does it work in 2006, 2007?.

Thanks

alex

"Tony Tanzillo" wrote in message
news:5149046@discussion.autodesk.com...
typedef Acad::ErrorStatus
(*acdbMakeDrawingPreviewPtr)
(AcDbDatabase* pDb, bool bUnused);

Acad::ErrorStatus MakeThumbnail(AcDbDatabase* pDb)
{
static acdbMakeDrawingPreviewPtr pFunc = NULL;
if( pFunc == NULL )
{
HMODULE hLib = GetArxModuleHandle("AcBlock.arx");
if( hLib == NULL )
return Acad::eInvalidInput;
void* pv = ::GetProcAddress(hLib,
"acdbMakeDrawingPreview");
if( pv == NULL )
return Acad::eInvalidInput;
pFunc = (acdbMakeDrawingPreviewPtr) pv;
}
if( pDb == NULL )
return Acad::eInvalidInput;
return (*pFunc)(pDb, false);
}

// moduleName (filename.arx) must be on PATH.

HMODULE GetArxModuleHandle(const char* moduleName)
{
HMODULE hLib = ::GetModuleHandle(moduleName);
if( hLib == NULL )
{
acrxLoadModule(moduleName, false, false);
hLib = ::GetModuleHandle(moduleName);
}
return hLib;
}


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"alex" wrote in message
news:5148244@discussion.autodesk.com...
Art:
It indeed returns NULL.
I am aware of the fact that wblock() doesn't create thumbnails, i'm just
looking for a way around it.
thanks

alex


"Art Cooney" wrote in message
news:5147493@discussion.autodesk.com...
How is it failing?

wblock() won't create a thumbnail in the database it is writing to, so
pNewDB->thumbnailBitmap() should return NULL.

"alex" wrote in message
news:5146780@discussion.autodesk.com...
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
Message 11 of 12

Anonymous
Not applicable
All that I can say is use undocumented functions at your own risk because
they can change or go away.

"alex" wrote in message
news:5149048@discussion.autodesk.com...
Art:
I just meant it fails for me. I didn't understand it works just for the
current db.
Do you have any comment to Tony's post of today?

Thanks,

alex

"Art Cooney" wrote in message
news:5148272@discussion.autodesk.com...
If you're aware that it returns NULL, then what do you mean by it "fails"?

There isn't any way to get wblock to create a thumbnail. The thumbnail is
generated by our graphics system and requires that the drawing be loaded in
the AutoCAD editor. The only way to get AutoCAD to put a thumbnail in the
drawing created by the wblock would be to open that drawing in the AutoCAD
editor and then save it.

"alex" wrote in message
news:5148244@discussion.autodesk.com...
Art:
It indeed returns NULL.
I am aware of the fact that wblock() doesn't create thumbnails, i'm just
looking for a way around it.
thanks

alex


"Art Cooney" wrote in message
news:5147493@discussion.autodesk.com...
How is it failing?

wblock() won't create a thumbnail in the database it is writing to, so
pNewDB->thumbnailBitmap() should return NULL.

"alex" wrote in message
news:5146780@discussion.autodesk.com...
Hi,

I'm trying using AcDbDatabase::thumbnailBitmap() and
AcDbDatabase::setThumbnailBitmap()
to generate a preview thumbnail on a new database before saving it, but it
fails on thumbnailBitmap().

Here is the code: (ObjectArx2002), no error checking

AcDbDatabase *pNewDB = NULL;//new database;
es = acdbHostApplicationServices()->workingDatabase()->wblock(pNewDB,
id);//add something to it
void * pThumbnail = pNewDB->thumbnailBitmap();//fails here
pNewDB->setThumbnailBitmap(pThumbnail);

The documentation is not very clear (or extensive) so i'm not sure i do the
right thing
TIA

alex
0 Likes
Message 12 of 12

Anonymous
Not applicable
"Art Cooney" wrote

>> All that I can say is use undocumented functions
>> at your own risk because they can change or go away.

Perhaps one reason we tend to rely on undocumented
APIs is because the above statement seems to apply
to documented APIs and their behavior as well.

For example, the way selection set ordering changed
in 2005, broke thousands of scripts that relied on the
previous behavior (selection set order == picked order).

IOW, when it comes to having the rug yanked out from
beneath us, it does not seem to matter much if it was
documented, or not.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com
0 Likes