首页 > 其他分享 >CAD ObjectArx开发之可停靠选项板

CAD ObjectArx开发之可停靠选项板

时间:2022-11-26 09:56:47浏览次数:35  
标签:pArxAppPaletteSet AUTO ACED ObjectArx 停靠 CFW ENTRY NULL CAD

环境:VS2010 + CAD2014

创建思路

1、创建ObjectARX项目,支持MFC

2、使用ObjectARX向导创建基类为CAdUiPaletteSet和CAdUiPalette的窗体类

3、在acrxEntryPoint.cpp中编写代码

(1)、在cpp文件中定义全局窗体指针

(2)、在On_kInitAppMsg初始化函数中添加窗台构建代码

(3)、在On_kUnloadAppMsg卸载函数中添加窗体资源释放代码

编译时可能出现的问题:

(1)、编译时出现#import "msxml.dll" named_guids不存在的错误。解决办法:不同操作系统,这个库的名称不一样:向导默认是适配WIN7系统的,如果是WIN10系统,可以尝试改成msxml4.dll或者msxml6.dll,编程时可以一个个尝试

详细步骤

1、创建ObjectARX项目,支持MFC

image
image
image
image
image
image

2、使用ObjectARX向导创建基类为CAdUiPaletteSet和CAdUiPalette的窗体类

1、CAdUiPalette窗体
image
2、CAdUiPaletteSet窗体
image

3、在acrxEntryPoint.cpp中编写代码

完整代码段
// (C) Copyright 2002-2012 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"
#include "ArxAppMain.h"

//-----------------------------------------------------------------------------
#define szRDS _RXST("")

//选项板
ArxAppPalette * pArxAppPalette = NULL;
ArxAppPaletteSet * pArxAppPaletteSet = NULL;
CAdUiPalette * pCAdUiPalette = NULL;

//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CFW_ArxAppApp : public AcRxArxApp {

public:
	CFW_ArxAppApp () : 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
		acutPrintf(_T("初始化选项板"));
		if(pArxAppPaletteSet == NULL){
			//创建选项板集合
			pArxAppPaletteSet = new ArxAppPaletteSet();
			CRect rect(0,0,400,400);
			pArxAppPaletteSet->Create(TEXT("工作空间"),WS_OVERLAPPED|WS_DLGFRAME,rect,acedGetAcadFrame(),PSS_EDIT_NAME|PSS_PROPERTIES_MENU|PSS_AUTO_ROLLUP|PSS_CLOSE_BUTTON);
			//创建选项板
			pArxAppPalette = new ArxAppPalette();
			pCAdUiPalette = new CAdUiPalette();

			pArxAppPalette->Create(WS_CHILD|WS_VISIBLE,TEXT("构件树"),pArxAppPaletteSet,PS_EDIT_NAME);
			pArxAppPaletteSet->AddPalette(pArxAppPalette);

			pCAdUiPalette->Create(WS_CHILD|WS_VISIBLE,TEXT("属性"),pArxAppPaletteSet,PS_EDIT_NAME);
			pArxAppPaletteSet->AddPalette(pCAdUiPalette);

			pArxAppPaletteSet->EnableDocking(CBRS_ALIGN_ANY);
			pArxAppPaletteSet->RestoreControlBar();

			acedGetAcadFrame()->ShowControlBar(pArxAppPaletteSet,TRUE,FALSE);

			if(pArxAppPaletteSet->GetOpacity() != 100){
				pArxAppPaletteSet->SetOpacity(100);
			}
		}

		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
		acutPrintf(_T("释放选项板"));
		if(pArxAppPaletteSet != NULL){
			pArxAppPaletteSet->DestroyWindow();
			delete pArxAppPaletteSet;
			pArxAppPaletteSet = NULL;
		}
		if(pArxAppPalette != NULL){
			pArxAppPalette->DestroyWindow();
			delete pArxAppPalette;
			pArxAppPalette = NULL;
		}
		if(pCAdUiPalette != NULL){
			pCAdUiPalette->DestroyWindow();
			delete pCAdUiPalette;
			pCAdUiPalette = NULL;
		}

		return (retCode) ;
	}

	virtual void RegisterServerComponents () {
	}
	
	// The ACED_ARXCOMMAND_ENTRY_AUTO macro can be applied to any static member 
	// function of the CFW_ArxAppApp class.
	// The function should take no arguments and return nothing.
	//
	// NOTE: ACED_ARXCOMMAND_ENTRY_AUTO has overloads where you can provide resourceid and
	// have arguments to define context and command mechanism.
	
	// ACED_ARXCOMMAND_ENTRY_AUTO(classname, group, globCmd, locCmd, cmdFlags, UIContext)
	// ACED_ARXCOMMAND_ENTRYBYID_AUTO(classname, group, globCmd, locCmdId, cmdFlags, UIContext)
	// only differs that it creates a localized name using a string in the resource file
	//   locCmdId - resource ID for localized command

	// Modal Command with localized name
	// ACED_ARXCOMMAND_ENTRY_AUTO(CFW_ArxAppApp, MyGroup, MyCommand, MyCommandLocal, ACRX_CMD_MODAL)
	static void MyGroupMyCommand () {
		// Put your command code here
		acutPrintf(_T("Hello Arx"));
	}

	// Modal Command with pickfirst selection
	// ACED_ARXCOMMAND_ENTRY_AUTO(CFW_ArxAppApp, MyGroup, MyPickFirst, MyPickFirstLocal, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET)
	static void MyGroupMyPickFirst () {
		ads_name result ;
		int iRet =acedSSGet (ACRX_T("_I"), NULL, NULL, NULL, result) ;
		if ( iRet == RTNORM )
		{
			// There are selected entities
			// Put your command using pickfirst set code here
		}
		else
		{
			// There are no selected entities
			// Put your command code here
		}
	}

	// Application Session Command with localized name
	// ACED_ARXCOMMAND_ENTRY_AUTO(CFW_ArxAppApp, MyGroup, MySessionCmd, MySessionCmdLocal, ACRX_CMD_MODAL | ACRX_CMD_SESSION)
	static void MyGroupMySessionCmd () {
		// Put your command code here
		acutPrintf(_T("Hello Arx"));

	}

	// The ACED_ADSFUNCTION_ENTRY_AUTO / ACED_ADSCOMMAND_ENTRY_AUTO macros can be applied to any static member 
	// function of the CFW_ArxAppApp class.
	// The function may or may not take arguments and have to return RTNORM, RTERROR, RTCAN, RTFAIL, RTREJ to AutoCAD, but use
	// acedRetNil, acedRetT, acedRetVoid, acedRetInt, acedRetReal, acedRetStr, acedRetPoint, acedRetName, acedRetList, acedRetVal to return
	// a value to the Lisp interpreter.
	//
	// NOTE: ACED_ADSFUNCTION_ENTRY_AUTO / ACED_ADSCOMMAND_ENTRY_AUTO has overloads where you can provide resourceid.
	
	//- ACED_ADSFUNCTION_ENTRY_AUTO(classname, name, regFunc) - this example
	//- ACED_ADSSYMBOL_ENTRYBYID_AUTO(classname, name, nameId, regFunc) - only differs that it creates a localized name using a string in the resource file
	//- ACED_ADSCOMMAND_ENTRY_AUTO(classname, name, regFunc) - a Lisp command (prefix C:)
	//- ACED_ADSCOMMAND_ENTRYBYID_AUTO(classname, name, nameId, regFunc) - only differs that it creates a localized name using a string in the resource file

	// Lisp Function is similar to ARX Command but it creates a lisp 
	// callable function. Many return types are supported not just string
	// or integer.
	// ACED_ADSFUNCTION_ENTRY_AUTO(CFW_ArxAppApp, MyLispFunction, false)
	static int ads_MyLispFunction () {
		//struct resbuf *args =acedGetArgs () ;
		
		// Put your command code here

		//acutRelRb (args) ;
		
		// Return a value to the AutoCAD Lisp Interpreter
		// acedRetNil, acedRetT, acedRetVoid, acedRetInt, acedRetReal, acedRetStr, acedRetPoint, acedRetName, acedRetList, acedRetVal

		return (RTNORM) ;
	}
	
} ;

//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CFW_ArxAppApp)

ACED_ARXCOMMAND_ENTRY_AUTO(CFW_ArxAppApp, MyGroup, MyCommand, MyCommandLocal, ACRX_CMD_MODAL, NULL)
ACED_ARXCOMMAND_ENTRY_AUTO(CFW_ArxAppApp, MyGroup, MyPickFirst, MyPickFirstLocal, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, NULL)
ACED_ARXCOMMAND_ENTRY_AUTO(CFW_ArxAppApp, MyGroup, MySessionCmd, MySessionCmdLocal, ACRX_CMD_MODAL | ACRX_CMD_SESSION, NULL)
ACED_ADSSYMBOL_ENTRY_AUTO(CFW_ArxAppApp, MyLispFunction, false)


编译时可能出现的问题解决:

(1)、编译时出现#import "msxml.dll" named_guids不存在的错误。解决办法:不同操作系统,这个库的名称不一样:向导默认是适配WIN7系统的,如果是WIN10系统,可以尝试改成msxml4.dll或者msxml6.dll,编程时可以一个个尝试

image

标签:pArxAppPaletteSet,AUTO,ACED,ObjectArx,停靠,CFW,ENTRY,NULL,CAD
From: https://www.cnblogs.com/chenshuangjian/p/16926939.html

相关文章

  • 工业物联网DCS和SCADA的区别
    如果你在工业自动化的企业环境中操作,可能听说过分布式控制系统(DCS)和监控和数据采集(SCADA)系统。DCS系统和SCADA系统有很多共同点,因为它们都被称为受控计算机系统,接......
  • 外观模式(Facade )
    就是封装!就是封装!就是封装!把一个很复杂的过程,包装成一个方法。调用的时候,只使用了一条语句,非常简介!非常美观! 比如:创建一个对象,只需要:new类名();它的内部......
  • ORCAD使用问题总结
    1、新添加元件,复制元件时自动编号处理:Options-Preference,如图3-175所示,来进行设置参数; 图3-175参数设置示意图 第三步,执行上述命令以后,会弹出如图3-176所示的界面,......
  • SCADA系统架构、类型和应用
    智能仪表和远程终端单元(RTU)/可编程逻辑控制器(PLC)的进步使得许多行业的过程控制都可以利用SCADA系统的优势轻松管理和操作。SCADA在多种应用中很受欢迎,如加工工业、石油......
  • CPP2nd CRTP Facade 模式
    书中源码不全,看看我这个?#include<iostream>#include<type_traits>#include<vector>#include<iterator>template<typenameDerived,typenameValue,typenameCa......
  • CAD命令学习日志
    CAD命令学习日志配置OP-打开配置选项UNITS-设置全局默认单位查找QSELECT-快速选择相同对象LIST-快速查看对象信息FILTER-对象过滤器F2-打开CAD文本窗......
  • antd Cascader实现多选功能
    antd中的组件cascader用于联级选择,但是只支持单选,在项目过程中经常会遇到多选的情况。这边将多选情况进行总结,以及附上实现代码。antd实现的单选功能如下:https://3x.ant.......
  • PipeCAD-布置管件
    PipeCAD-布置管件[email protected],三维管道设计软件,三维工厂设计软件,三维配管软件 目前PipeCAD管道建模功能已经可以使用,欢迎大家使用并反馈。感......
  • AutoCAD DIMANGULAR 钝角
    DIMANGULAR钝角需使用"三点角度标注"(而非"角度标注")。执行DIMANGULAR命令,进入步骤:"选择圆弧、圆、直线或<指定顶点>:",按'空格/回车';"DIMANGULAR""指定角的顶点:"("......
  • CSharp: Facade Pattern in donet 6
     ///<summary>///外观模式FacadePattern///银行///</summary>publicclassBank{publicboolIsUntrustworthy(Custome......