Đến nội dung


Hình ảnh
- - - - -

Lập trình C++ cho Autocad LT


  • Please log in to reply
2 replies to this topic

#1 mua_buon12

mua_buon12

    biết vẽ circle

  • Members
  • PipPip
  • 34 Bài viết
Điểm đánh giá: 0 (bình thường)

Đã gửi 29 October 2009 - 09:53 AM

Dear all!
Các bác ơi Tôi down được nguồn code C++ dùng để load file *.Vlx vào trong autocad LT. Tuy nhiên Tôi vẫn chưa chạy được em upload lên nhờ các cao thủ sửa giúp.(Tôi dùng Autocad LT 2006).Đa tạ các bác trước nhé.

- file :RxExports.def
EXPORTS acrxEntryPoint
acrxGetApiVersion
- file :VLXLoad.sln
Microsoft Visual Studio Solution File, Format Version 10.0
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VLXLoad15", "VLXLoad15\VLXLoad15.vcproj", "{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VLXLoad16", "VLXLoad16\VLXLoad16.vcproj", "{409587AE-0891-447F-BD6B-42E95D3DD247}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VLXLoad17", "VLXLoad17\VLXLoad17.vcproj", "{C2E234DD-0D14-40AC-86C2-326971F1D0C1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VLXLoad18", "VLXLoad18\VLXLoad18.vcproj", "{F8CD557D-C5B6-404C-9D88-251B48EBB87F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}.Debug|Win32.ActiveCfg = Debug|Win32
{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}.Debug|Win32.Build.0 = Debug|Win32
{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}.Debug|x64.ActiveCfg = Debug|Win32
{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}.Release|Mixed Platforms.Build.0 = Release|Win32
{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}.Release|Win32.ActiveCfg = Release|Win32
{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}.Release|Win32.Build.0 = Release|Win32
{B551A282-DE2B-4F1A-8A1F-CCB2D6549222}.Release|x64.ActiveCfg = Release|Win32
{409587AE-0891-447F-BD6B-42E95D3DD247}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{409587AE-0891-447F-BD6B-42E95D3DD247}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{409587AE-0891-447F-BD6B-42E95D3DD247}.Debug|Win32.ActiveCfg = Debug|Win32
{409587AE-0891-447F-BD6B-42E95D3DD247}.Debug|Win32.Build.0 = Debug|Win32
{409587AE-0891-447F-BD6B-42E95D3DD247}.Debug|x64.ActiveCfg = Debug|Win32
{409587AE-0891-447F-BD6B-42E95D3DD247}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{409587AE-0891-447F-BD6B-42E95D3DD247}.Release|Mixed Platforms.Build.0 = Release|Win32
{409587AE-0891-447F-BD6B-42E95D3DD247}.Release|Win32.ActiveCfg = Release|Win32
{409587AE-0891-447F-BD6B-42E95D3DD247}.Release|Win32.Build.0 = Release|Win32
{409587AE-0891-447F-BD6B-42E95D3DD247}.Release|x64.ActiveCfg = Release|Win32
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Debug|Win32.ActiveCfg = Debug|Win32
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Debug|Win32.Build.0 = Debug|Win32
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Debug|x64.ActiveCfg = Debug|x64
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Debug|x64.Build.0 = Debug|x64
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Release|Mixed Platforms.ActiveCfg = Release|x64
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Release|Mixed Platforms.Build.0 = Release|x64
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Release|Win32.ActiveCfg = Release|Win32
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Release|Win32.Build.0 = Release|Win32
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Release|x64.ActiveCfg = Release|x64
{C2E234DD-0D14-40AC-86C2-326971F1D0C1}.Release|x64.Build.0 = Release|x64
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Debug|Mixed Platforms.ActiveCfg = Debug|x64
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Debug|Mixed Platforms.Build.0 = Debug|x64
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Debug|Win32.ActiveCfg = Debug|Win32
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Debug|Win32.Build.0 = Debug|Win32
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Debug|x64.ActiveCfg = Debug|x64
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Debug|x64.Build.0 = Debug|x64
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Release|Mixed Platforms.ActiveCfg = Release|x64
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Release|Mixed Platforms.Build.0 = Release|x64
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Release|Win32.ActiveCfg = Release|Win32
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Release|Win32.Build.0 = Release|Win32
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Release|x64.ActiveCfg = Release|x64
{F8CD557D-C5B6-404C-9D88-251B48EBB87F}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
- file: VLXLoad.cpp
#define STRICT

#include "aced.h"
#include "acdocman.h"
#include "rxregsvc.h"

#pragma comment (linker, "/align:4096") //Minimize executable size

//macros to use version independent ACHAR type
#if (_ACADTARGET <= 16)
typedef char ACHAR;
#define ACRX_T(x) x
#endif
typedef ACHAR* LPACRXSTR;
typedef const ACHAR* LPCACRXSTR;


// Function prototypes
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved );
AcRx::AppRetCode acrxEntryPoint( AcRx::AppMsgCode msg, void* pkt );
void LoadVLX( LPCACRXSTR pszVlxFilename = NULL );
void DefineAdsFunctions();
void InvokeAdsFunction();
void AdsGetPath();
LPCACRXSTR NameOfVlxLoadFunction();
LPCACRXSTR NameOfGetPathFunction();
LPCACRXSTR GetTargetFilename();

extern "C" int ads_queueexpr( LPACRXSTR );


// Global variables
HINSTANCE _hdllInstance;

// Function implementations
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved )
{
if( ul_reason_for_call == DLL_PROCESS_ATTACH )
_hdllInstance = (HINSTANCE)hModule;
return TRUE;
}


AcRx::AppRetCode acrxEntryPoint( AcRx::AppMsgCode msg, void* pkt)
{
switch( msg )
{
case AcRx::kInitAppMsg:
acrxUnlockApplication( pkt );
acrxDynamicLinker->registerAppMDIAware( pkt );
break;
case AcRx::kInvkSubrMsg:
InvokeAdsFunction();
break;
case AcRx::kLoadDwgMsg:
DefineAdsFunctions();
break;
case AcRx::kUnloadDwgMsg:
break;
case AcRx::kUnloadAppMsg:
break;
case AcRx::kSaveMsg:
break;
case AcRx::kEndMsg:
break;
case AcRx::kQuitMsg:
break;
case AcRx::kCfgMsg:
break;
default:
break;
}
return AcRx::kRetOK;
}


void LoadVLX( LPCACRXSTR pszVlxFilename /*= NULL*/ )
{
ACHAR szPath[210] = ACRX_T("");
::GetModuleFileName( _hdllInstance, szPath, MAX_PATH );
ACHAR* pCursor;
for( pCursor = szPath; *pCursor != ACRX_T('\'); pCursor++ )
{
if( *pCursor == ACRX_T('\\') )
*pCursor = ACRX_T('/');
}
int idxSearch = lstrlen( szPath ) - 1;
for( ; idxSearch >= 0; idxSearch-- )
{
if( szPath[idxSearch] == ACRX_T('/') ||
szPath[idxSearch] == ACRX_T(':') )
break;
}
idxSearch++;
if( pszVlxFilename )
lstrcpy( szPath + idxSearch, pszVlxFilename );
else
{
pCursor = szPath + idxSearch;
while( *pCursor && *pCursor++ != ACRX_T('.') );
lstrcpy( pCursor, ACRX_T("vlx") );
}
ACHAR szExecuteString[255] = ACRX_T("(vl-load-com)(vl-load-all \"");
lstrcat( szExecuteString, szPath );
lstrcat( szExecuteString, ACRX_T("\")(princ)\n") );
ads_queueexpr( szExecuteString );
}


void DefineAdsFunctions()
{
static bool bFirstTime = true;
if( bFirstTime )
{
bFirstTime = false;
acedDefun( NameOfVlxLoadFunction(), 1 );
ACHAR szLoadVlxExpression[64] = ACRX_T("(");
lstrcat( szLoadVlxExpression, NameOfVlxLoadFunction() );
lstrcat( szLoadVlxExpression, ACRX_T(")") );
ads_queueexpr( szLoadVlxExpression );
}
acedDefun( NameOfGetPathFunction(), 2 );
}


void InvokeAdsFunction()
{
switch( acedGetFunCode() )
{
case 1:
acedUndef( NameOfVlxLoadFunction(), 1 );
LoadVLX();
acedRetList( NULL );
break;
default:
AdsGetPath();
break;
}
}


void AdsGetPath()
{
static ACHAR szPath[MAX_PATH] = ACRX_T("");
if( szPath[0] == ACRX_T('\') )
{
::GetModuleFileName( _hdllInstance, szPath, MAX_PATH );
ACHAR* pCursor = szPath;
int idxSearch = lstrlen( szPath ) - 1;
for( ; idxSearch >= 0; idxSearch-- )
{
if( szPath[idxSearch] == ACRX_T('\\') ||
szPath[idxSearch] == ACRX_T('/') ||
szPath[idxSearch] == ACRX_T(':') )
break;
}
szPath[++idxSearch] = ACRX_T('\');
}
acedRetStr( szPath );
}


LPCACRXSTR NameOfVlxLoadFunction()
{
static ACHAR szVlxLoadFunctionName[64] = ACRX_T("VlxLoad-");
static bool bInitialized = false;
if( !bInitialized )
{
lstrcat( szVlxLoadFunctionName, GetTargetFilename() );
bInitialized = true;
}
return szVlxLoadFunctionName;
}


LPCACRXSTR NameOfGetPathFunction()
{
static ACHAR szGetPathFunctionName[64] = ACRX_T("GetPathOf");
static bool bInitialized = false;
if( !bInitialized )
{
lstrcat( szGetPathFunctionName, GetTargetFilename() );
bInitialized = true;
}
return szGetPathFunctionName;
}


LPCACRXSTR GetTargetFilename()
{
static ACHAR szFilename[MAX_PATH] = ACRX_T("");
if( szFilename[0] == ACRX_T('\') )
{
ACHAR szPath[MAX_PATH];
::GetModuleFileName( _hdllInstance, szPath, MAX_PATH );
int idxSearch = lstrlen( szPath ) - 1;
bool bExtensionRemoved = false;
for( ; idxSearch >= 0; idxSearch-- )
{
if( !bExtensionRemoved && szPath[idxSearch] == ACRX_T('.') )
{
bExtensionRemoved = true;
szPath[idxSearch] = ACRX_T('\');
continue;
}
if( szPath[idxSearch] == ACRX_T('\\') ||
szPath[idxSearch] == ACRX_T('/') ||
szPath[idxSearch] == ACRX_T(':') )
break;
}
idxSearch++;
lstrcpy( szFilename, szPath + idxSearch );
}
return szFilename;
}
  • 0
Khi Lập Trình Kiến Thức Là Một Phần, Nghệ Thuật Mới Là Tất Cả.

#2 anhcos

anhcos

    biết lệnh hatchedit

  • Advance Member
  • PipPipPipPip
  • 260 Bài viết
Điểm đánh giá: 170 (tàm tạm)

Đã gửi 29 October 2009 - 06:00 PM

- file :VLXLoad.sln
Microsoft Visual Studio Solution File, Format Version 10.0
# Visual Studio 2008

Cái này là file của Microsoft Visual Studio.NET 2008, cài bộ đó vào máy tính.
Bộ này chừng 2GB, cài hơi lâu.

Xong mở cái file *.sln, dịch nó ra exe xem nó làm việc ntn.
  • 0
Clear sky!

MF Rock collection.

#3 mua_buon12

mua_buon12

    biết vẽ circle

  • Members
  • PipPip
  • 34 Bài viết
Điểm đánh giá: 0 (bình thường)

Đã gửi 11 November 2009 - 02:46 PM

Các bác ơi, Làm sao để autocad (cad LT) gọi được các thư viện bên ngoài đưa vào nhỉ?
Em thấy có mấy phần mềm khi cài ra là load được lisp cho autocad LT(ví dụ: LT-Extender,Toolbox2009...).Bác nào cao thủ giúp em với



- file :VLXLoad.sln
Microsoft Visual Studio Solution File, Format Version 10.0
# Visual Studio 2008

Cái này là file của Microsoft Visual Studio.NET 2008, cài bộ đó vào máy tính.
Bộ này chừng 2GB, cài hơi lâu.

Xong mở cái file *.sln, dịch nó ra exe xem nó làm việc ntn.


  • 0
Khi Lập Trình Kiến Thức Là Một Phần, Nghệ Thuật Mới Là Tất Cả.