明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2276|回复: 3

新手提问,如何运行ARX

[复制链接]
发表于 2006-6-22 14:08:00 | 显示全部楼层 |阅读模式

以下代码是ARX2007中地例题,已编译成ARX文件,在ACD2007已经加载

可我如何来查看我运行地结果啊?
先输入这个命令ASDK_MKENTS,然后呢???

谁来帮帮我啊,非常谢谢

-------------------------------------------------------------------

#if defined(_DEBUG) && !defined(AC_FULL_DEBUG)
#error _DEBUG should not be defined except in internal Adesk debug builds
#endif

#include <string.h>
#include <aced.h>
#include <dbents.h>
#include <dbsymtb.h>
#include <dbgroup.h>
#include <dbapserv.h>
#include "tchar.h"

AcDbObjectId createLine();
AcDbObjectId createCircle();
void createNewLayer();
void createGroup();
Acad::ErrorStatus changeColor(AcDbObjectId, Adesk::UInt16);

AcDbObjectId createLine()
{
    AcGePoint3d startPt(4.0, 2.0, 0.0);
    AcGePoint3d endPt(10.0, 7.0, 0.0);
    AcDbLine *pLine = new AcDbLine(startPt, endPt);

    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 createCircle()
{
    AcGePoint3d center(9.0, 3.0, 0.0);
    AcGeVector3d normal(0.0, 0.0, 1.0);
    AcDbCircle *pCirc = new AcDbCircle(center, normal, 2.0);

    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;
}

void createNewLayer()
{
    AcDbLayerTable *pLayerTable;
    acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable, AcDb::kForWrite);

    AcDbLayerTableRecord *pLayerTableRecord = new AcDbLayerTableRecord;
    pLayerTableRecord->setName(_T("ASDK_MYLAYER"));

 pLayerTable->add(pLayerTableRecord);
    pLayerTable->close();
    pLayerTableRecord->close();
}

void createGroup(AcDbObjectIdArray& objIds, TCHAR* pGroupName)
{
    AcDbGroup *pGroup = new AcDbGroup(pGroupName);
 
    AcDbDictionary *pGroupDict;
    acdbHostApplicationServices()->workingDatabase()->getGroupDictionary(pGroupDict, AcDb::kForWrite);

    AcDbObjectId pGroupId;
    pGroupDict->setAt(pGroupName, pGroup, pGroupId);
    pGroupDict->close();

    for (int i = 0; i < objIds.length(); i++) {
        pGroup->append(objIds);
    }

 pGroup->close();
}

Acad::ErrorStatus changeColor(AcDbObjectId entId, Adesk::UInt16 newColor)
{
    AcDbEntity *pEntity;
    acdbOpenObject(pEntity, entId,
        AcDb::kForWrite);

    pEntity->setColorIndex(newColor);
    pEntity->close();

    return Acad::eOk;
}

void runIt()
{
    createNewLayer();

    AcDbObjectIdArray idArr;

    idArr.append(createLine());
    idArr.append(createCircle());

    changeColor(idArr.last(), 1);
    createGroup(idArr, _T("ASDK_TEST_GROUP"));
}

void initApp()
{
    acedRegCmds->addCommand(_T("ASDK_MAKE_ENTS"),
                            _T("ASDK_MKENTS"),
                            _T("MKENTS"),
                            ACRX_CMD_MODAL,
                            runIt);
}

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

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;
}

发表于 2006-6-22 16:57:00 | 显示全部楼层

上述程序是生成一个直线和一个圆.

程序加栽后,键入命令后,在屏幕上生成一条直线和一个圆.

 

 楼主| 发表于 2006-6-22 17:06:00 | 显示全部楼层

楼上地,谢谢你啊

问题是这样地,我键入命令ASDK_MKENTS后

上面一点反应都没有,怎么回事呀

 楼主| 发表于 2006-6-22 18:01:00 | 显示全部楼层
我知道了,因为太小太小,看不清楚,放大就看到了,谢谢楼上楼上地啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 23:44 , Processed in 0.160121 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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