明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: hulei_accp

初学建议

  [复制链接]
 楼主| 发表于 2005-10-24 22:34:00 | 显示全部楼层

谁能告诉我画椭圆的例子啊。如:void drawEllipse(...)

{};

发表于 2005-10-25 08:07:00 | 显示全部楼层
谢谢
 楼主| 发表于 2005-10-27 23:32:00 | 显示全部楼层

合肥有招聘autocad二次开发的公司吗?有哪位知道,告诉我一声。我现在开发gis,但不是我的兴趣和强项。

 楼主| 发表于 2005-10-27 23:39:00 | 显示全部楼层
王老师,你能不能在网上搞个cad二次开发的培训啊?
 楼主| 发表于 2005-11-1 23:26:00 | 显示全部楼层
发个程序给大家看看,这是我照书做的,在VC++6.0 ,autocad2002下编译通过.
 楼主| 发表于 2005-11-1 23:32:00 | 显示全部楼层
1212
 楼主| 发表于 2005-11-2 22:33:00 | 显示全部楼层

cpp文件:

#include "aced.h"
#include "rxregsvc.h"
#include "string.h"
#include "aced.h"
#include "dbents.h"
#include "dbsymtb.h"
#include "dbgroup.h"
#include "dbapserv.h"

AcDbObjectId createNewLine();
AcDbObjectId createNewCircle();
AcDbObjectId createNewLayer();

void createNewGroup();

Acad::ErrorStatus changeColor(AcDbObjectId,Adesk::UInt16);


AcDbObjectId createNewLine()
{
 AcGePoint3d startPoint(5.0,4.0,0.0);
 AcGePoint3d endPoint(15.0,10.0,0.0);
 AcDbLine *pLine=new AcDbLine(startPoint,endPoint);
 AcDbBlockTable *pBlockTable;
 acdbHostApplicationServices()->workingDatabase()
   ->getSymbolTable(pBlockTable,AcDb::kForRead);
 AcDbBlockTableRecord *pBlockTableRecord;
 pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);
 pBlockTable->close();
 AcDbObjectId lineId;
 pBlockTableRecord->appendAcDbEntity(lineId,pLine);
 pBlockTableRecord->close();
 pLine->close();
 return lineId;

}

AcDbObjectId createNewCircle()
{
 AcGePoint3d center(10.0,7.0,0.0);
 AcGeVector3d normal(0.0,0.0,1.0);
 AcDbCircle *pCirc=new AcDbCircle(center,normal,4.5);
 AcDbBlockTable *pBlockTable;
 acdbHostApplicationServices()->workingDatabase()
    ->getSymbolTable(pBlockTable,AcDb::kForRead);
 AcDbBlockTableRecord *pBlockTableRecord;
 pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);
 pBlockTable->close();
 AcDbObjectId circleId;
 pBlockTableRecord->appendAcDbEntity(circleId,pCirc);
 pBlockTableRecord->close();
 pCirc->close();
 return circleId;
}

AcDbObjectId createNewLayer()
{
 AcDbLayerTable *pLayerTable;
 acdbHostApplicationServices()->workingDatabase()
    ->getSymbolTable(pLayerTable,AcDb::kForWrite);
 AcDbLayerTableRecord *pLayerTableRecord=new AcDbLayerTableRecord;
 pLayerTableRecord->setName("MYNewLayer");
 AcDbObjectId pLayerId;
 pLayerTable->add(pLayerId,pLayerTableRecord);
 pLayerTable->close();
 pLayerTableRecord->close();
 return pLayerId;
}

Acad::ErrorStatus
changeColor(AcDbObjectId entId,Adesk::UInt16 newColor)
{
 AcDbEntity *pEntity;
 acdbOpenObject(pEntity,entId,AcDb::kForWrite);
 pEntity->setColorIndex(newColor);
 pEntity->close();
 return Acad::eOk;
}

void createNewGroup (AcDbObjectIdArray & objIds,char * pGroupName,AcDbObjectId pLayerId)
{
 AcDbGroup *pGroup=new AcDbGroup(pGroupName);
 for(int i=0; i<objIds.length(); i++)
 {
  pGroup->append(objIds);
  
 }
 AcDbDictionary *pGroupDict;
 acdbHostApplicationServices()->workingDatabase()
    ->getGroupDictionary(pGroupDict,AcDb::kForWrite);
  AcDbObjectId pGroupId;
  pGroupDict->setAt(pGroupName,pGroup,pGroupId);
  pGroup->setLayer(pLayerId);
  pGroupDict->close();
  pGroup->close();
}

void runIt()
{
 AcDbObjectId newLayerId=createNewLayer();
 AcDbObjectIdArray idArray;
 idArray.append(createNewLine());
 idArray.append(createNewCircle());
 changeColor(idArray.first(),1);
 changeColor(idArray.last(),3);
 createNewGroup(idArray,"MyNewGroup",newLayerId);
}

void initApp()
{
 acedRegCmds->addCommand("ASDK_MAKE_ENTITIES",
       "ASDK_MakeNewEnts",
       "MakeNewEnts",
       ACRX_CMD_MODAL,
       runIt);
}

void unloadApp()
{
  acedRegCmds->removeGroup("ASDK_MAKE_ENTITIES");
}

extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg,void * appId)
{
 switch(msg)
 {
 case AcRx::kInitAppMsg:
   acrxDynamicLinker->unlockApplication(appId);
   acrxDynamicLinker->registerAppMDIAware(appId);
   initApp();
   break;
 case AcRx::kUnloadAppMsg:
   unloadApp();
 }
 return AcRx::kRetOK;
}

 楼主| 发表于 2005-11-2 23:01:00 | 显示全部楼层

这是画直线的程序cpp:

#include "aced.h"
#include "rxregsvc.h"
#include "dbents.h"
#include "dbapserv.h"

void initApp();
void unloadApp();
void DrawLine();

void initApp()
{
 acedRegCmds->addCommand("Draw_Line",
       "line_hu",
       "line_hu",
       ACRX_CMD_MODAL,
       DrawLine);
}

void unloadApp()
{
 acedRegCmds->removeGroup("Draw_Line");
}


void DrawLine()
{
 AcGePoint3d startPt(4.0,2.0,0.0);
 AcGePoint3d endPt(10.0,7.0,0.0);
 


 AcGeVector3d normal(0.0,0.0,1.0);
 AcDbLine *pLine=new AcDbLine(startPt,endPt);
 pLine->setColorIndex(3);

 AcDbBlockTable * pBlockTable;
 acdbHostApplicationServices()->workingDatabase()
     ->getSymbolTable(pBlockTable,AcDb::kForRead);
 AcDbBlockTableRecord *pBlockTableRecord;
 pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);
 pBlockTable->close();
 AcDbObjectId lineId;
 pBlockTableRecord->appendAcDbEntity(lineId,pLine);
 pBlockTableRecord->close();
 pLine->close();

}

extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void *pkt)
{
 switch(msg)
 {
 case AcRx::kInitAppMsg:
  acrxDynamicLinker->unlockApplication(pkt);
  initApp();
  break;
 case AcRx::kUnloadAppMsg:
  unloadApp();
  break;
 default :
  break;
 }
 return AcRx::kRetOK;
}

 

 楼主| 发表于 2005-11-3 23:11:00 | 显示全部楼层

这是我写的例子,供大家参考.

 楼主| 发表于 2005-11-6 21:31:00 | 显示全部楼层
哪里有autocad二次开发的培训啊?我愿报名.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 05:38 , Processed in 0.192226 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表