//
very easy an simple
// code by s91
// s91.ctgu.cn@gmail.com
//
// (C) Copyright 2002-2005 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
// -----------------------------------------------------------------------------
// ----- acrxEntryPoint.h
// -----------------------------------------------------------------------------
#include " StdAfx.h "
#include " resource.h "
#include < dbsymtb.h >
// -----------------------------------------------------------------------------
#define szRDS _RXST("")
// -----------------------------------------------------------------------------
// ----- ObjectARX EntryPoint
class CLayerChooserApp : public AcRxArxApp ... {
public:
CLayerChooserApp () : AcRxArxApp () ...{}
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) ...{
// TODO: Load dependencies here
// You *must* call On_kInitAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
// TODO: Add your initialization code here
return (retCode) ;
}
virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) ...{
// TODO: Add your code here
// You *must* call On_kUnloadAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;
// TODO: Unload dependencies here
return (retCode) ;
}
virtual void RegisterServerComponents () ...{
}
public:
// - LayerChooser._LayerChooser command (do not rename)
static void LayerChooser_LayerChooser(void)
...{
// Add your code for command LayerChooser._LayerChooser here
ACHAR result[16];
ACHAR t1[1],t2[1];//存储图层名及输入的字符用与比较
//ACHAR *LayerName = NULL;
acedGetString(0,_T("Please Input the Layer Name: "),result);
//acutPrintf(result);
t1[0] = result[0];
int n = 0;//判断是否找到图层
AcDbLayerTable *pLayerTbl;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pLayerTbl, AcDb::kForRead);
// Create a new iterator that starts at table
// beginning and skips deleted.
//
//code by s91
// s91.ctgu.cn@gmail.com
AcDbLayerTableIterator *pLayerIterator;
pLayerTbl->newIterator(pLayerIterator);
// Walk the table, getting every table record and
// printing the linetype name.
//
AcDbLayerTableRecord *pLayerTableRcd;
ACHAR *pLtName;
for (; !pLayerIterator->done(); pLayerIterator->step())
...{
pLayerIterator->getRecord(pLayerTableRcd, AcDb::kForRead);
pLayerTableRcd->getName(pLtName);
pLayerTableRcd->close();
//acutPrintf(_T(" Linetype name is: %s"), pLtName);
t2[0] = pLtName[0];
//n = _tcscmp(t1,t2);
if (t1[0] == t2[0])
...{
// LayerName = pLtName;
struct resbuf pResult;
::acedGetVar(_T("CLAYER"),&pResult);//取得当前图层
pResult.resval.rstring = pLtName;
::acedSetVar(_T("CLAYER"), &pResult);//将输入的图层设为当前层
//相当于命令 CLAYER LAYERNAME
//acutPrintf(_T(" Linetype name is: %s"), pResult.resval.rstring);
free(pLtName);
n = 1;//如果图层找到,则将n赋值为1
}
else
...{
free(pLtName);
}
}
if (n == 0)
...{
acutPrintf(_T(" The layer was not found!"));
}
delete pLayerIterator;
pLayerTbl->close();
// acutPrintf(_T(" Linetype name"));
// acutPrintf(_T(" Linetype name is: %s"), pResult.resval.rstring);
}
} ;
// -----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CLayerChooserApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CLayerChooserApp, LayerChooser, _LayerChooser, LayerChooser, ACRX_CMD_TRANSPARENT, NULL)
// code by s91
// s91.ctgu.cn@gmail.com
//
// (C) Copyright 2002-2005 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
// -----------------------------------------------------------------------------
// ----- acrxEntryPoint.h
// -----------------------------------------------------------------------------
#include " StdAfx.h "
#include " resource.h "
#include < dbsymtb.h >
// -----------------------------------------------------------------------------
#define szRDS _RXST("")
// -----------------------------------------------------------------------------
// ----- ObjectARX EntryPoint
class CLayerChooserApp : public AcRxArxApp ... {
public:
CLayerChooserApp () : AcRxArxApp () ...{}
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) ...{
// TODO: Load dependencies here
// You *must* call On_kInitAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
// TODO: Add your initialization code here
return (retCode) ;
}
virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) ...{
// TODO: Add your code here
// You *must* call On_kUnloadAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;
// TODO: Unload dependencies here
return (retCode) ;
}
virtual void RegisterServerComponents () ...{
}
public:
// - LayerChooser._LayerChooser command (do not rename)
static void LayerChooser_LayerChooser(void)
...{
// Add your code for command LayerChooser._LayerChooser here
ACHAR result[16];
ACHAR t1[1],t2[1];//存储图层名及输入的字符用与比较
//ACHAR *LayerName = NULL;
acedGetString(0,_T("Please Input the Layer Name: "),result);
//acutPrintf(result);
t1[0] = result[0];
int n = 0;//判断是否找到图层
AcDbLayerTable *pLayerTbl;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pLayerTbl, AcDb::kForRead);
// Create a new iterator that starts at table
// beginning and skips deleted.
//
//code by s91
// s91.ctgu.cn@gmail.com
AcDbLayerTableIterator *pLayerIterator;
pLayerTbl->newIterator(pLayerIterator);
// Walk the table, getting every table record and
// printing the linetype name.
//
AcDbLayerTableRecord *pLayerTableRcd;
ACHAR *pLtName;
for (; !pLayerIterator->done(); pLayerIterator->step())
...{
pLayerIterator->getRecord(pLayerTableRcd, AcDb::kForRead);
pLayerTableRcd->getName(pLtName);
pLayerTableRcd->close();
//acutPrintf(_T(" Linetype name is: %s"), pLtName);
t2[0] = pLtName[0];
//n = _tcscmp(t1,t2);
if (t1[0] == t2[0])
...{
// LayerName = pLtName;
struct resbuf pResult;
::acedGetVar(_T("CLAYER"),&pResult);//取得当前图层
pResult.resval.rstring = pLtName;
::acedSetVar(_T("CLAYER"), &pResult);//将输入的图层设为当前层
//相当于命令 CLAYER LAYERNAME
//acutPrintf(_T(" Linetype name is: %s"), pResult.resval.rstring);
free(pLtName);
n = 1;//如果图层找到,则将n赋值为1
}
else
...{
free(pLtName);
}
}
if (n == 0)
...{
acutPrintf(_T(" The layer was not found!"));
}
delete pLayerIterator;
pLayerTbl->close();
// acutPrintf(_T(" Linetype name"));
// acutPrintf(_T(" Linetype name is: %s"), pResult.resval.rstring);
}
} ;
// -----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CLayerChooserApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CLayerChooserApp, LayerChooser, _LayerChooser, LayerChooser, ACRX_CMD_TRANSPARENT, NULL)