stl export

stl export

Anonymous
Not applicable
762 Views
3 Replies
Message 1 of 4

stl export

Anonymous
Not applicable

Hi,

I am trying to export 3d object (Part) of autocad into STL by using COM API, but getting error message.

As per export functrionality (in AutoCAD), you can export BMP or STL in same manner. By code is working fine if i change the extentsion value for 2nd argument of IAcadDocument->Export() function, to BMP instead of STL.

Entire geometry is in +Ve XYZ octane and selection handle (3rd argument) is also having 1 object.

Waiting for response.

Thanks

Nikhil Gothankar

763 Views
3 Replies
Replies (3)
Message 2 of 4

Balaji_Ram
Alumni
Alumni

The Export COM API method doesn't work for STL. You may consider using "SendCommand" and use the "STLOUT" command.



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 4

Anonymous
Not applicable
Hi, I don't know how to use send commad, esp. if there is a selection is also involved and how i will know whether the command executed successfully or not? Can some help me in this. Nikhil
0 Likes
Message 4 of 4

Balaji_Ram
Alumni
Alumni

Here is a sample code :

 

#include "acadi.h"

#pragma warning( disable : 4278 )
#import "acax18ENU.tlb" no_implementation raw_interfaces_only named_guids
#pragma warning( default : 4278 )

 

static void Test(void)
 {
  CWinApp *pApp=acedGetAcadWinApp();
  if (!pApp)
   return;

  HRESULT  hRes;
  LPDISPATCH pDisp=NULL;

  pDisp=pApp->GetIDispatch(TRUE);
  if (!pDisp)
   return;

  CComPtr<AutoCAD::IAcadApplication> pComApp;
  hRes=pDisp->QueryInterface(AutoCAD::IID_IAcadApplication, (void**)&pComApp);
  if (FAILED(hRes))
   return;

  CComPtr<AutoCAD::IAcadDocument> pComDoc;
  hRes=pComApp->get_ActiveDocument(&pComDoc);
  if (FAILED(hRes))
   return;

  hRes = pComDoc->SendCommand(_bstr_t("setvar FILEDIA 0 "));
  if (FAILED(hRes))
   return;

  hRes = pComDoc->SendCommand(_bstr_t("STLOUT ")); // Command
  if (FAILED(hRes))
   return;

  hRes = pComDoc->SendCommand(_bstr_t("All  ")); // Select All
  if (FAILED(hRes))
   return;

  hRes = pComDoc->SendCommand(_bstr_t("No "));  // Is Binary : No
  if (FAILED(hRes))
   return;

  hRes = pComDoc->SendCommand(_bstr_t("c:\\Temp\\MyStl.stl\n"));  // File name
  if (FAILED(hRes))
   return;
 }



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes