a problem when send message to intellicad

#1
Hello everyone
i have a problem when i send message to intellicad with ::sendmessageA in a .exe file.
the message content is "(command "script" "test.scr")\n"
intellicad receive the message, but it can't deal with "\n", just "(command "script" "test.scr") "showed on the intellicad.
i also tried "(command "script" "test.scr") ", the result is the same.
But it is ok for Autocad.

So, how can i send a "\n" to intellicad?
Thanks.

#4
Danielm103 wrote:I think you would be better off using the COM interface.
yes, i think "using the com interface" is a good method. Can you give me a closer description of how to use it?
thanks.

#6
wuzixiao wrote:
Danielm103 wrote:I think you would be better off using the COM interface.
yes, i think "using the com interface" is a good method. Can you give me a closer description of how to use it?
thanks.
Here is an example of how to work with Intellicad’s com interface via C++

Code: Select all

#include "stdafx.h"
#include "atlbase.h"
#include "IcadTLB.h" //<-- you can find this in the API directory

int _tmain(int argc, _TCHAR* argv[])
{
  //init
  CoInitialize(NULL);

  //get the application
  CComPtr<IIcadApplication> application = NULL;
  CLSID	applicationClass;
  CLSIDFromProgID( OLESTR("icad.application"), &applicationClass );

  CComPtr<IUnknown>	unknown;
  HRESULT result =  GetActiveObject( applicationClass, NULL, &unknown );
  if( SUCCEEDED( result ) )
  {
    CComQIPtr<IIcadApplication>	app = unknown;
    application = app;
  }
  else
  {
    printf("Failed to get Application");
    return -1;
  }

  //get the active document.. not needed here, but left it in as an example
  CComPtr<IIcadDocument> document;
  HRESULT hr = application->get_ActiveDocument( &document );
  if(FAILED(hr))
  {
    printf("Failed to get active document");
    return -1;
  }

  //make our BSTR
  BSTR bstrScript = SysAllocString(L"C:/Spline.scr"); 

  //run the sript
  hr = application->RunScript(bstrScript);
  if(FAILED(hr))
  {
    printf("Failed to run script");
  }

  SysFreeString(bstrScript);

  return 0;
}

#7
Danielm103 wrote:
wuzixiao wrote:
Danielm103 wrote:I think you would be better off using the COM interface.
yes, i think "using the com interface" is a good method. Can you give me a closer description of how to use it?
thanks.
Here is an example of how to work with Intellicad’s com interface via C++

Code: Select all

#include "stdafx.h"
#include "atlbase.h"
#include "IcadTLB.h" //<-- you can find this in the API directory

int _tmain(int argc, _TCHAR* argv[])
{
  //init
  CoInitialize(NULL);

  //get the application
  CComPtr<IIcadApplication> application = NULL;
  CLSID	applicationClass;
  CLSIDFromProgID( OLESTR("icad.application"), &applicationClass );

  CComPtr<IUnknown>	unknown;
  HRESULT result =  GetActiveObject( applicationClass, NULL, &unknown );
  if( SUCCEEDED( result ) )
  {
    CComQIPtr<IIcadApplication>	app = unknown;
    application = app;
  }
  else
  {
    printf("Failed to get Application");
    return -1;
  }

  //get the active document.. not needed here, but left it in as an example
  CComPtr<IIcadDocument> document;
  HRESULT hr = application->get_ActiveDocument( &document );
  if(FAILED(hr))
  {
    printf("Failed to get active document");
    return -1;
  }

  //make our BSTR
  BSTR bstrScript = SysAllocString(L"C:/Spline.scr"); 

  //run the sript
  hr = application->RunScript(bstrScript);
  if(FAILED(hr))
  {
    printf("Failed to run script");
  }

  SysFreeString(bstrScript);

  return 0;
}

thank you very much.
but i can't find "IcadTLB.h" in the dictionary api.
my intellicad version is intellicad2000