hulei_accp
发表于 2005-10-24 22:34:00
<P>谁能告诉我画椭圆的例子啊。如:void drawEllipse(...)</P>
<P>{};</P>
errBoy
发表于 2005-10-25 08:07:00
谢谢
hulei_accp
发表于 2005-10-27 23:32:00
<P>合肥有招聘autocad二次开发的公司吗?有哪位知道,告诉我一声。我现在开发gis,但不是我的兴趣和强项。</P>
hulei_accp
发表于 2005-10-27 23:39:00
王老师,你能不能在网上搞个cad二次开发的培训啊?
hulei_accp
发表于 2005-11-1 23:26:00
发个程序给大家看看,这是我照书做的,在VC++6.0 ,autocad2002下编译通过.
hulei_accp
发表于 2005-11-1 23:32:00
1212
hulei_accp
发表于 2005-11-2 22:33:00
<P>cpp文件:</P>
<P>#include "aced.h"<BR>#include "rxregsvc.h"<BR>#include "string.h"<BR>#include "aced.h"<BR>#include "dbents.h"<BR>#include "dbsymtb.h"<BR>#include "dbgroup.h"<BR>#include "dbapserv.h"</P>
<P>AcDbObjectId createNewLine();<BR>AcDbObjectId createNewCircle();<BR>AcDbObjectId createNewLayer();</P>
<P>void createNewGroup();</P>
<P>Acad::ErrorStatus changeColor(AcDbObjectId,Adesk::UInt16);</P>
<P><BR>AcDbObjectId createNewLine()<BR>{<BR> AcGePoint3d startPoint(5.0,4.0,0.0);<BR> AcGePoint3d endPoint(15.0,10.0,0.0);<BR> AcDbLine *pLine=new AcDbLine(startPoint,endPoint);<BR> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pBlockTable,AcDb::kForRead);<BR> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR> pBlockTable->close();<BR> AcDbObjectId lineId;<BR> pBlockTableRecord->appendAcDbEntity(lineId,pLine);<BR> pBlockTableRecord->close();<BR> pLine->close();<BR> return lineId;</P>
<P>}</P>
<P>AcDbObjectId createNewCircle()<BR>{<BR> AcGePoint3d center(10.0,7.0,0.0);<BR> AcGeVector3d normal(0.0,0.0,1.0);<BR> AcDbCircle *pCirc=new AcDbCircle(center,normal,4.5);<BR> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pBlockTable,AcDb::kForRead);<BR> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR> pBlockTable->close();<BR> AcDbObjectId circleId;<BR> pBlockTableRecord->appendAcDbEntity(circleId,pCirc);<BR> pBlockTableRecord->close();<BR> pCirc->close();<BR> return circleId;<BR>}</P>
<P>AcDbObjectId createNewLayer()<BR>{<BR> AcDbLayerTable *pLayerTable;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pLayerTable,AcDb::kForWrite);<BR> AcDbLayerTableRecord *pLayerTableRecord=new AcDbLayerTableRecord;<BR> pLayerTableRecord->setName("MYNewLayer");<BR> AcDbObjectId pLayerId;<BR> pLayerTable->add(pLayerId,pLayerTableRecord);<BR> pLayerTable->close();<BR> pLayerTableRecord->close();<BR> return pLayerId;<BR>}</P>
<P>Acad::ErrorStatus<BR>changeColor(AcDbObjectId entId,Adesk::UInt16 newColor)<BR>{<BR> AcDbEntity *pEntity;<BR> acdbOpenObject(pEntity,entId,AcDb::kForWrite);<BR> pEntity->setColorIndex(newColor);<BR> pEntity->close();<BR> return Acad::eOk;<BR>}</P>
<P>void createNewGroup (AcDbObjectIdArray & objIds,char * pGroupName,AcDbObjectId pLayerId)<BR>{<BR> AcDbGroup *pGroup=new AcDbGroup(pGroupName);<BR> for(int i=0; i<objIds.length(); i++)<BR> {<BR> pGroup->append(objIds);<BR> <BR> }<BR> AcDbDictionary *pGroupDict;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getGroupDictionary(pGroupDict,AcDb::kForWrite);<BR> AcDbObjectId pGroupId;<BR> pGroupDict->setAt(pGroupName,pGroup,pGroupId);<BR> pGroup->setLayer(pLayerId);<BR> pGroupDict->close();<BR> pGroup->close();<BR>}</P>
<P>void runIt()<BR>{<BR> AcDbObjectId newLayerId=createNewLayer();<BR> AcDbObjectIdArray idArray;<BR> idArray.append(createNewLine());<BR> idArray.append(createNewCircle());<BR> changeColor(idArray.first(),1);<BR> changeColor(idArray.last(),3);<BR> createNewGroup(idArray,"MyNewGroup",newLayerId);<BR>}</P>
<P>void initApp()<BR>{<BR> acedRegCmds->addCommand("ASDK_MAKE_ENTITIES",<BR> "ASDK_MakeNewEnts",<BR> "MakeNewEnts",<BR> ACRX_CMD_MODAL,<BR> runIt);<BR>}</P>
<P>void unloadApp()<BR>{<BR> acedRegCmds->removeGroup("ASDK_MAKE_ENTITIES");<BR>}</P>
<P>extern "C" AcRx::AppRetCode<BR>acrxEntryPoint(AcRx::AppMsgCode msg,void * appId)<BR>{<BR> switch(msg)<BR> {<BR> case AcRx::kInitAppMsg:<BR> acrxDynamicLinker->unlockApplication(appId);<BR> acrxDynamicLinker->registerAppMDIAware(appId);<BR> initApp();<BR> break;<BR> case AcRx::kUnloadAppMsg:<BR> unloadApp();<BR> }<BR> return AcRx::kRetOK;<BR>}</P>
hulei_accp
发表于 2005-11-2 23:01:00
<P>这是画直线的程序cpp:</P>
<P>#include "aced.h"<BR>#include "rxregsvc.h"<BR>#include "dbents.h"<BR>#include "dbapserv.h"</P>
<P>void initApp();<BR>void unloadApp();<BR>void DrawLine();</P>
<P>void initApp()<BR>{<BR> acedRegCmds->addCommand("Draw_Line",<BR> "line_hu",<BR> "line_hu",<BR> ACRX_CMD_MODAL,<BR> DrawLine);<BR>}</P>
<P>void unloadApp()<BR>{<BR> acedRegCmds->removeGroup("Draw_Line");<BR>}</P>
<P><BR>void DrawLine()<BR>{<BR> AcGePoint3d startPt(4.0,2.0,0.0);<BR> AcGePoint3d endPt(10.0,7.0,0.0);<BR> </P>
<P><BR> AcGeVector3d normal(0.0,0.0,1.0);<BR> AcDbLine *pLine=new AcDbLine(startPt,endPt);<BR> pLine->setColorIndex(3);</P>
<P> AcDbBlockTable * pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pBlockTable,AcDb::kForRead);<BR> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR> pBlockTable->close();<BR> AcDbObjectId lineId;<BR> pBlockTableRecord->appendAcDbEntity(lineId,pLine);<BR> pBlockTableRecord->close();<BR> pLine->close();</P>
<P>}</P>
<P>extern "C" AcRx::AppRetCode<BR>acrxEntryPoint(AcRx::AppMsgCode msg, void *pkt)<BR>{<BR> switch(msg)<BR> {<BR> case AcRx::kInitAppMsg:<BR> acrxDynamicLinker->unlockApplication(pkt);<BR> initApp();<BR> break;<BR> case AcRx::kUnloadAppMsg:<BR> unloadApp();<BR> break;<BR> default :<BR> break;<BR> }<BR> return AcRx::kRetOK;<BR>}</P>
<P> </P>
hulei_accp
发表于 2005-11-3 23:11:00
<P>这是我写的例子,供大家参考.</P>
hulei_accp
发表于 2005-11-6 21:31:00
哪里有autocad二次开发的培训啊?我愿报名.