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>&nbsp;AcGePoint3d startPoint(5.0,4.0,0.0);<BR>&nbsp;AcGePoint3d endPoint(15.0,10.0,0.0);<BR>&nbsp;AcDbLine *pLine=new AcDbLine(startPoint,endPoint);<BR>&nbsp;AcDbBlockTable *pBlockTable;<BR>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<BR>&nbsp;&nbsp;&nbsp;-&gt;getSymbolTable(pBlockTable,AcDb::kForRead);<BR>&nbsp;AcDbBlockTableRecord *pBlockTableRecord;<BR>&nbsp;pBlockTable-&gt;getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR>&nbsp;pBlockTable-&gt;close();<BR>&nbsp;AcDbObjectId lineId;<BR>&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(lineId,pLine);<BR>&nbsp;pBlockTableRecord-&gt;close();<BR>&nbsp;pLine-&gt;close();<BR>&nbsp;return lineId;</P>
<P>}</P>
<P>AcDbObjectId createNewCircle()<BR>{<BR>&nbsp;AcGePoint3d center(10.0,7.0,0.0);<BR>&nbsp;AcGeVector3d normal(0.0,0.0,1.0);<BR>&nbsp;AcDbCircle *pCirc=new AcDbCircle(center,normal,4.5);<BR>&nbsp;AcDbBlockTable *pBlockTable;<BR>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<BR>&nbsp;&nbsp;&nbsp;&nbsp;-&gt;getSymbolTable(pBlockTable,AcDb::kForRead);<BR>&nbsp;AcDbBlockTableRecord *pBlockTableRecord;<BR>&nbsp;pBlockTable-&gt;getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR>&nbsp;pBlockTable-&gt;close();<BR>&nbsp;AcDbObjectId circleId;<BR>&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(circleId,pCirc);<BR>&nbsp;pBlockTableRecord-&gt;close();<BR>&nbsp;pCirc-&gt;close();<BR>&nbsp;return circleId;<BR>}</P>
<P>AcDbObjectId createNewLayer()<BR>{<BR>&nbsp;AcDbLayerTable *pLayerTable;<BR>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<BR>&nbsp;&nbsp;&nbsp;&nbsp;-&gt;getSymbolTable(pLayerTable,AcDb::kForWrite);<BR>&nbsp;AcDbLayerTableRecord *pLayerTableRecord=new AcDbLayerTableRecord;<BR>&nbsp;pLayerTableRecord-&gt;setName("MYNewLayer");<BR>&nbsp;AcDbObjectId pLayerId;<BR>&nbsp;pLayerTable-&gt;add(pLayerId,pLayerTableRecord);<BR>&nbsp;pLayerTable-&gt;close();<BR>&nbsp;pLayerTableRecord-&gt;close();<BR>&nbsp;return pLayerId;<BR>}</P>
<P>Acad::ErrorStatus<BR>changeColor(AcDbObjectId entId,Adesk::UInt16 newColor)<BR>{<BR>&nbsp;AcDbEntity *pEntity;<BR>&nbsp;acdbOpenObject(pEntity,entId,AcDb::kForWrite);<BR>&nbsp;pEntity-&gt;setColorIndex(newColor);<BR>&nbsp;pEntity-&gt;close();<BR>&nbsp;return Acad::eOk;<BR>}</P>
<P>void createNewGroup (AcDbObjectIdArray &amp; objIds,char * pGroupName,AcDbObjectId pLayerId)<BR>{<BR>&nbsp;AcDbGroup *pGroup=new AcDbGroup(pGroupName);<BR>&nbsp;for(int i=0; i&lt;objIds.length(); i++)<BR>&nbsp;{<BR>&nbsp;&nbsp;pGroup-&gt;append(objIds);<BR>&nbsp;&nbsp;<BR>&nbsp;}<BR>&nbsp;AcDbDictionary *pGroupDict;<BR>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<BR>&nbsp;&nbsp;&nbsp;&nbsp;-&gt;getGroupDictionary(pGroupDict,AcDb::kForWrite);<BR>&nbsp;&nbsp;AcDbObjectId pGroupId;<BR>&nbsp;&nbsp;pGroupDict-&gt;setAt(pGroupName,pGroup,pGroupId);<BR>&nbsp;&nbsp;pGroup-&gt;setLayer(pLayerId);<BR>&nbsp;&nbsp;pGroupDict-&gt;close();<BR>&nbsp;&nbsp;pGroup-&gt;close();<BR>}</P>
<P>void runIt()<BR>{<BR>&nbsp;AcDbObjectId newLayerId=createNewLayer();<BR>&nbsp;AcDbObjectIdArray idArray;<BR>&nbsp;idArray.append(createNewLine());<BR>&nbsp;idArray.append(createNewCircle());<BR>&nbsp;changeColor(idArray.first(),1);<BR>&nbsp;changeColor(idArray.last(),3);<BR>&nbsp;createNewGroup(idArray,"MyNewGroup",newLayerId);<BR>}</P>
<P>void initApp()<BR>{<BR>&nbsp;acedRegCmds-&gt;addCommand("ASDK_MAKE_ENTITIES",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ASDK_MakeNewEnts",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"MakeNewEnts",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ACRX_CMD_MODAL,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;runIt);<BR>}</P>
<P>void unloadApp()<BR>{<BR>&nbsp;&nbsp;acedRegCmds-&gt;removeGroup("ASDK_MAKE_ENTITIES");<BR>}</P>
<P>extern "C" AcRx::AppRetCode<BR>acrxEntryPoint(AcRx::AppMsgCode msg,void * appId)<BR>{<BR>&nbsp;switch(msg)<BR>&nbsp;{<BR>&nbsp;case AcRx::kInitAppMsg:<BR>&nbsp;&nbsp;&nbsp;acrxDynamicLinker-&gt;unlockApplication(appId);<BR>&nbsp;&nbsp;&nbsp;acrxDynamicLinker-&gt;registerAppMDIAware(appId);<BR>&nbsp;&nbsp;&nbsp;initApp();<BR>&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;case AcRx::kUnloadAppMsg:<BR>&nbsp;&nbsp;&nbsp;unloadApp();<BR>&nbsp;}<BR>&nbsp;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>&nbsp;acedRegCmds-&gt;addCommand("Draw_Line",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"line_hu",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"line_hu",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ACRX_CMD_MODAL,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawLine);<BR>}</P>
<P>void unloadApp()<BR>{<BR>&nbsp;acedRegCmds-&gt;removeGroup("Draw_Line");<BR>}</P>
<P><BR>void DrawLine()<BR>{<BR>&nbsp;AcGePoint3d startPt(4.0,2.0,0.0);<BR>&nbsp;AcGePoint3d endPt(10.0,7.0,0.0);<BR>&nbsp;</P>
<P><BR>&nbsp;AcGeVector3d normal(0.0,0.0,1.0);<BR>&nbsp;AcDbLine *pLine=new AcDbLine(startPt,endPt);<BR>&nbsp;pLine-&gt;setColorIndex(3);</P>
<P>&nbsp;AcDbBlockTable * pBlockTable;<BR>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;getSymbolTable(pBlockTable,AcDb::kForRead);<BR>&nbsp;AcDbBlockTableRecord *pBlockTableRecord;<BR>&nbsp;pBlockTable-&gt;getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR>&nbsp;pBlockTable-&gt;close();<BR>&nbsp;AcDbObjectId lineId;<BR>&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(lineId,pLine);<BR>&nbsp;pBlockTableRecord-&gt;close();<BR>&nbsp;pLine-&gt;close();</P>
<P>}</P>
<P>extern "C" AcRx::AppRetCode<BR>acrxEntryPoint(AcRx::AppMsgCode msg, void *pkt)<BR>{<BR>&nbsp;switch(msg)<BR>&nbsp;{<BR>&nbsp;case AcRx::kInitAppMsg:<BR>&nbsp;&nbsp;acrxDynamicLinker-&gt;unlockApplication(pkt);<BR>&nbsp;&nbsp;initApp();<BR>&nbsp;&nbsp;break;<BR>&nbsp;case AcRx::kUnloadAppMsg:<BR>&nbsp;&nbsp;unloadApp();<BR>&nbsp;&nbsp;break;<BR>&nbsp;default :<BR>&nbsp;&nbsp;break;<BR>&nbsp;}<BR>&nbsp;return AcRx::kRetOK;<BR>}</P>
<P>&nbsp;</P>

hulei_accp 发表于 2005-11-3 23:11:00

<P>这是我写的例子,供大家参考.</P>

hulei_accp 发表于 2005-11-6 21:31:00

哪里有autocad二次开发的培训啊?我愿报名.
页: 1 [2] 3
查看完整版本: 初学建议