static void ShapeNames(void)
{
struct SHAPESTRUCT {
unsigned short iShapeNumber; // shape number
unsigned short iDefBytes; // number of data bytes in shape, 2000 max
unsigned char *lpszShapeName; // pointer to shapename
unsigned char *lpszSpecBytes; // pointer to shape specification bytes
};
char SHAPE10[] = "AutoCAD-86 shapes 1.0";
char SHAPE11[] = "AutoCAD-86 shapes 1.1";
resbuf *rbfile = NULL;
if (RTNORM == acedGetFileNavDialog("Select shape file","","shx","ShapeNames",0,&rbfile))
{
FILE *fshx = fopen(rbfile->resval.rstring,"rb"); acutRelRb(rbfile);
if (fshx) {
char desc[32];
fread (desc,sizeof(desc),1,fshx);
if (!strstr(desc,SHAPE10) && !strstr(desc,SHAPE11)) {
acutPrintf("\nIt is not shape file!");
fclose(fshx);
return;
}
fseek (fshx, (long)0x1c, SEEK_SET);
unsigned short iNumShapes = 0;
fread (&iNumShapes, sizeof (iNumShapes), 1, fshx);
SHAPESTRUCT *lpShapeList, *lpShape;
lpShapeList = (SHAPESTRUCT *)calloc(iNumShapes, sizeof (*lpShapeList));
for (int i=0; i < iNumShapes; i++) {
lpShape = lpShapeList + i;
fread(&(lpShape->iShapeNumber), sizeof (lpShape->iShapeNumber), 1, fshx);
fread(&(lpShape->iDefBytes), sizeof (lpShape->iDefBytes), 1, fshx);
}
if (lpShapeList->iShapeNumber != 0) { // it is shape file
for (int i = 0; i < iNumShapes; i++) {
lpShape = lpShapeList + i;
lpShape->lpszShapeName = (unsigned char *)(malloc (lpShape->iDefBytes));
fread (lpShape->lpszShapeName, sizeof (*lpShape->lpszShapeName), lpShape->iDefBytes, fshx);
acutPrintf("\nShape N%d = %s", i, lpShape->lpszShapeName);
free(lpShape->lpszShapeName);
}
} else {
acutPrintf("\nIt is not shape file!");
}
free(lpShapeList);
fclose(fshx);
}
}
}
This code was written 5 years ago (before UNICODE "revolution" in AutoCAD). That is why you have to rewrite this code using UNICODE.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
