CAD ObjectARX二次开发之绘制第一条直线
2022/7/6 23:31:05
本文主要是介绍CAD ObjectARX二次开发之绘制第一条直线,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、配置命令环境
参考此教程配置:https://www.cnblogs.com/chenshuangjian/p/16450346.html
二、代码编写
工程目录结构:
代码编写:
// (C) Copyright 2002-2007 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.cpp //----------------------------------------------------------------------------- #include "StdAfx.h" #include "resource.h" //----------------------------------------------------------------------------- #define szRDS _RXST("Arx") //----------------------------------------------------------------------------- //----- ObjectARX EntryPoint class CDemo_DrawLineApp : public AcRxArxApp { public: CDemo_DrawLineApp () : 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 () { } // - ArxDemo_DrawLine._MyCommand1 command (do not rename) static void ArxDemo_DrawLine_MyCommand1(void) { // Add your code for command ArxDemo_DrawLine._MyCommand1 here AcGePoint3d P1(0,0,0); AcGePoint3d P2(10,10,10); //定义直线 AcDbLine *pLine = new AcDbLine(P1,P2); AcDbBlockTable *pBlockTable =NULL; //获取块表 acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable,AcDb::kForRead); AcDbBlockTableRecord *pBockTableRecord = NULL; //获取模型空间块表记录 pBlockTable->getAt(ACDB_MODEL_SPACE,pBockTableRecord,AcDb::kForWrite); AcDbObjectId lineId; //将直线添加到块表记录 pBockTableRecord->appendAcDbEntity(lineId,pLine); //关闭释放资源 pBlockTable->close(); pBockTableRecord->close(); pLine->close(); } } ; //----------------------------------------------------------------------------- IMPLEMENT_ARX_ENTRYPOINT(CDemo_DrawLineApp) ACED_ARXCOMMAND_ENTRY_AUTO(CDemo_DrawLineApp, ArxDemo_DrawLine, _MyCommand1, MyCommand1, ACRX_CMD_TRANSPARENT, NULL)
三、编译测试
这篇关于CAD ObjectARX二次开发之绘制第一条直线的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-25【机器学习(二)】分类和回归任务-决策树(Decision Tree,DT)算法-Sentosa_DSML社区版
- 2024-11-23增量更新怎么做?-icode9专业技术文章分享
- 2024-11-23压缩包加密方案有哪些?-icode9专业技术文章分享
- 2024-11-23用shell怎么写一个开机时自动同步远程仓库的代码?-icode9专业技术文章分享
- 2024-11-23webman可以同步自己的仓库吗?-icode9专业技术文章分享
- 2024-11-23在 Webman 中怎么判断是否有某命令进程正在运行?-icode9专业技术文章分享
- 2024-11-23如何重置new Swiper?-icode9专业技术文章分享
- 2024-11-23oss直传有什么好处?-icode9专业技术文章分享
- 2024-11-23如何将oss直传封装成一个组件在其他页面调用时都可以使用?-icode9专业技术文章分享
- 2024-11-23怎么使用laravel 11在代码里获取路由列表?-icode9专业技术文章分享