C language > Work in progress

Pelles-C + OLE for access to AutoCAD

<< < (3/11) > >>

sergey:
I see:
#include "acad.h"
It is from acad.exe ?
But can't compile acad.exe by 'FtypeLib.exe' - ERROR!

TimoVJL:
No, it's from ACAD.TLB (v. 2000) created with FTypeLib.
Use your version of header, as example still needs IID_IAcadApplication from there.

sergey:
Paste from the previous 'acax17enu.h' ...
It really works!
And while AutoCadTest.exe = 22.5 kB

I did not know which way to look.
Even I started to do something in Python and VC ++.
But it did not work.

Now, for the expansion of this program. I will write functions.

I do not know how to thank you for your help.
THANK YOU! THANK YOU! THANK YOU!

TimoVJL:
If someone don't want to include needlessly GUIDs to exe, here is some ideas :
--- Code: ---#define WIN32_LEAN_AND_MEAN
#include <windows.h>

const IID IID_ACAD_15 = {0x8e75d910,0x3d21,0x11d2,{0x85,0xc4,0x08,0x00,0x09,0xa0,0xc6,0x26}};
const IID IID_ACAD_16 = {0x93bc4e71,0xafe7,0x4aa7,{0xbc,0x07,0xf8,0x0a,0xcd,0xb6,0x72,0xd5}};
const IID IID_ACAD_17 = {0x8f17437c,0x2efb,0x4fc4,{0x81,0x88,0xee,0xfa,0x50,0xfe,0x71,0x47}};
const IID IID_ACAD_18 = {0x84f323fc,0xc179,0x4704,{0x87,0xe7,0xe3,0xd5,0x76,0xc2,0x59,0x9e}};

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
HKEY hk;
TCHAR szTmp[260];
//ReadRegStr(HKEY_CLASSES_ROOT, "AutoCAD.Application\\CurVer", NULL, szTmp, sizeof(szTmp));
//if (RegOpenKey(HKEY_CLASSES_ROOT, TEXT("AutoCAD.Application\\CurVer"), &hk) == ERROR_SUCCESS) {
if (RegOpenKey(HKEY_CURRENT_USER, TEXT("SOFTWARE\\Classes\\AutoCAD.Application\\CurVer"), &hk) == ERROR_SUCCESS) {
DWORD dwType, dwSize;
dwSize = sizeof(szTmp);
RegQueryValueEx(hk, NULL, 0, &dwType, (BYTE *)szTmp, &dwSize);
RegCloseKey(hk);
}
//int nVer = *(WORD*)&szTmp[20];
IID *pIID = NULL;
if (*(WORD*)&szTmp[20] == 0x3531) pIID = (IID*)&IID_ACAD_15;
else if (*(WORD*)&szTmp[20] == 0x3631) pIID = (IID*)&IID_ACAD_16;
else if (*(WORD*)&szTmp[20] == 0x3731) pIID = (IID*)&IID_ACAD_17;
else if (*(WORD*)&szTmp[20] == 0x3831) pIID = (IID*)&IID_ACAD_18;
pIID = NULL;
if (szTmp[21] == '5') pIID = (IID*)&IID_ACAD_15;
else if (szTmp[21] == '6') pIID = (IID*)&IID_ACAD_16;
else if (szTmp[21] == '7') pIID = (IID*)&IID_ACAD_17;
else if (szTmp[21] == '8') pIID = (IID*)&IID_ACAD_18;
if (pIID) MessageBox(0,szTmp,0,MB_OK);

return 0;
}
BOOL ReadRegStr(HKEY hKey, const TCHAR *szKey, const TCHAR *szSubKey, TCHAR *szValue, DWORD nSize)
{
HKEY hk;
DWORD dwType, dwSize;
if (RegOpenKey(hKey, szKey, &hk) == ERROR_SUCCESS)
{
dwSize = nSize;
RegQueryValueEx(hk, szSubKey, 0, &dwType, (BYTE *)szValue, &dwSize);
RegCloseKey(hk);
return TRUE;
}
return FALSE;
}
--- End code ---
 

sergey:
Interesting idea, I will read and think.
In the meantime, here's what happens.

Practical work in AutoCAD often associated with any drawing, which already has some of the objects.
The program that loads AutoCAD with a blank drawing less in demand.
But I could not do so at the start of the program checked already downloaded copy AutoCAD (with the right to work drawing) and connect to the copy.

Therefore, I chose another way.
After loading AutoCAD with a blank drawing, the program calls the built-in in AutoCAD dialogue <FileOpen>.
And loads selected for the work a drawing.
After that will work functions that perform something in the user-selected drawing.

I left in a line of code, a program that creates 2 points and the line.
They do not interfere with the future work program, but it's nice please me - reminding help prfessionalny programmer on the most difficult stage of the creation of this program.
Thanks to him.

For some unknown reason to me the macro-command only works when you double call.
That line of code:

--- Code: --- if (pACadDoc) {
IAcadDocument_SendCommand(pACadDoc, L"_open ");
IAcadDocument_SendCommand(pACadDoc, L"_OPEN");
}

--- End code ---
And here are the options that do not work:

--- Code: --- /*
if (pUtility) {
IAcadUtility_Prompt(pUtility, L"_open ");
IAcadUtility_Prompt(pUtility, L"_OPEN ");
// variants of:
//(pUtility)->lpVtbl->Prompt(pUtility, L"_open ");
//IAcadUtility_Prompt(pUtility, L"_open \\n");
}
*/

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version