ObjectArx调用cad内部命令

2023-12-17 13:04

本文主要是介绍ObjectArx调用cad内部命令,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

PhdArxCadCmd.h

#pragma once
#include <memory>
#include <mutex>class PhdArxCadCmd final
{
public:static PhdArxCadCmd* Instance();private:PhdArxCadCmd() = default;static std::unique_ptr<PhdArxCadCmd> m_self;	//声明静态对象public://关闭命令回显void EchoOff() const;//刷新图纸bool CallRegen() const;//设置标注线性比例bool SetDimLineScale(double dValue) const;//设置标注全局比例bool SetDimScale(double dValue) const;//设置区域覆盖是否显示边框bool SetWipeoutShow(bool bShow = false) const;//设置倒圆角半径bool SetFilletRadius(double dRadius) const;//调用cad命令倒圆角bool FilletByCommand(AcDbObjectId& idArc,const AcDbObjectId& idLine1, const AcDbObjectId& idLine2) const;//定位实体bool OrientationEnt(const AcDbObjectId& idEnt) const;//zoom显示全部实体bool ZoomAllEnt() const;//zoom窗口bool ZoomWindow(const AcGePoint3d& ptMin,const AcGePoint3d& ptMax) const;};//宏定义
#define g_ArxCadCmd PhdArxCadCmd::Instance()

PhdArxCadCmd.cpp

#include "stdafx.h"
#include "../stdafx.h"
#include "PhdArxCadCmd.h"
#include <acedCmdNF.h>//初始化静态成员变量
std::unique_ptr<PhdArxCadCmd> PhdArxCadCmd::m_self;PhdArxCadCmd* PhdArxCadCmd::Instance()
{//判断智能指针对象是否为空if (m_self.get() == nullptr)	//双重检查{//定义互斥量对象static std::mutex mutex;//定义智能锁对象std::lock_guard<std::mutex> alock(mutex);//判断智能指针对象对否为空if (m_self.get() == nullptr){//创建实例,并绑定智能指针m_self.reset(new PhdArxCadCmd);}}return m_self.get();
}void PhdArxCadCmd::EchoOff() const
{resbuf var;int nRs = acedGetVar(_T("CMDECHO"), &var);if (var.resval.rint)//打开了命令回显{//ObjectARX已经将acedCommand函数升级为acedCommandS函数, 使用该函数需要添加头文件”acedCmdNF.h”。acedCommandS(RTSTR, _T("CMDECHO"), RTSHORT, 0, RTNONE);}
}bool PhdArxCadCmd::CallRegen() const
{int nRet = acedCommandS(RTSTR, _T("REGEN"), RTNONE);return nRet == RTNORM;
}bool PhdArxCadCmd::SetDimLineScale(double dValue) const
{//int nRet = acedCommand(RTSTR, _T("DIMLFAC"), RTREAL, dValue, RTNONE);int nRet = acedCommandS(RTSTR, _T("DIMLFAC"), RTREAL, dValue, RTNONE);return nRet == RTNORM;
}bool PhdArxCadCmd::SetDimScale(double dValue) const
{//int nRet = acedCommand(RTSTR, _T("DIMSCALE"), RTREAL, dValue, RTNONE);int nRet = acedCommandS(RTSTR, _T("DIMSCALE"), RTREAL, dValue, RTNONE);return nRet == RTNORM;
}bool PhdArxCadCmd::SetWipeoutShow(bool bShow /*= false*/) const
{int nRet;if (bShow){//nRet = acedCommand(RTSTR, _T("wipeout"), RTSTR, _T("f"), RTSTR, _T("on"), RTNONE);nRet = acedCommandS(RTSTR, _T("wipeout"), RTSTR, _T("f"), RTSTR, _T("on"), RTNONE);}else{//nRet = acedCommand(RTSTR, _T("wipeout"), RTSTR, _T("f"), RTSTR, _T("off"), RTNONE);nRet = acedCommandS(RTSTR, _T("wipeout"), RTSTR, _T("f"), RTSTR, _T("off"), RTNONE);}return nRet == RTNORM;
}bool PhdArxCadCmd::SetFilletRadius(double dRadius) const
{//int nRet = acedCommand(RTSTR, _T("_fillet"), RTSTR, _T("r"), RTREAL, dRadius, RTNONE);int nRet = acedCommandS(RTSTR, _T("_fillet"), RTSTR, _T("r"), RTREAL, dRadius, RTNONE);return nRet == RTNORM;
}bool PhdArxCadCmd::FilletByCommand(AcDbObjectId& idArc, const AcDbObjectId& idLine1, const AcDbObjectId& idLine2) const
{AcDbPoint* pt = new AcDbPoint(AcGePoint3d::kOrigin);AcDbObjectId ptId = g_ArxUtility->PostToModelSpace(pt);ads_name name1, name2;acdbGetAdsName(name1, idLine1);acdbGetAdsName(name2, idLine2);//int nRet = acedCommand(RTSTR, _T("_fillet"), RTENAME, name1, RTENAME, name2, RTNONE);int nRet = acedCommandS(RTSTR, _T("_fillet"), RTENAME, name1, RTENAME, name2, RTNONE);if (nRet != RTNORM){g_ArxCommand->DeleteEnt(ptId);return false;}//得到圆弧idads_name lastEnt;acdbEntLast(lastEnt);acdbGetObjectId(idArc, lastEnt);if (idArc == ptId){g_ArxCommand->DeleteEnt(ptId);return false;}else{g_ArxCommand->DeleteEnt(ptId);return true;}
}bool PhdArxCadCmd::OrientationEnt(const AcDbObjectId& idEnt) const
{AcDbEntityPointer pEnt(idEnt, AcDb::kForWrite);if (Acad::eOk != pEnt.openStatus())return false;AcDbExtents extent;pEnt->getGeomExtents(extent);pEnt->highlight();	//设置实体为高亮状态AcGePoint3d ptMin = extent.minPoint();AcGePoint3d ptMax = extent.maxPoint();double dWidth = fabs(ptMax.x - ptMin.x);double dHeight = fabs(ptMax.y - ptMin.y);AcGePoint3d CenterPt;CenterPt.x = (ptMax.x + ptMin.x) / 2;CenterPt.y = (ptMax.y + ptMin.y) / 2;ptMax.x = CenterPt.x + (dWidth / 2) * 2;ptMax.y = CenterPt.y + (dHeight / 2) * 2;ptMin.x = CenterPt.x - (dWidth / 2) * 2;ptMin.y = CenterPt.y - (dHeight / 2) * 2;CString strCommand;strCommand.Format(_T("ZOOM\nw\n%lf,%lf,%lf\n%lf,%lf,%lf\n"), ptMin.x, ptMin.y, ptMin.z, ptMax.x, ptMax.y, ptMax.z);acDocManager->sendStringToExecute(acDocManager->curDocument(), strCommand, true, false, false);return true;
}bool PhdArxCadCmd::ZoomAllEnt() const
{//int nRet = acedCommand(RTSTR, _T("zoom"), RTSTR, _T("a"), RTNONE);int nRet = acedCommandS(RTSTR, _T("zoom"), RTSTR, _T("a"), RTNONE);return nRet == RTNORM;
}bool PhdArxCadCmd::ZoomWindow(const AcGePoint3d& ptMin, const AcGePoint3d& ptMax) const
{int nRet = acedCommandS(RTSTR, _T("zoom"), RTSTR, _T("w"), RT3DPOINT, asDblArray(ptMin),RT3DPOINT, asDblArray(ptMax), RTNONE);return nRet == RTNORM;
}

这篇关于ObjectArx调用cad内部命令的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/504456

相关文章

C#集成DeepSeek模型实现AI私有化的流程步骤(本地部署与API调用教程)

《C#集成DeepSeek模型实现AI私有化的流程步骤(本地部署与API调用教程)》本文主要介绍了C#集成DeepSeek模型实现AI私有化的方法,包括搭建基础环境,如安装Ollama和下载DeepS... 目录前言搭建基础环境1、安装 Ollama2、下载 DeepSeek R1 模型客户端 ChatBo

linux打包解压命令方式

《linux打包解压命令方式》文章介绍了Linux系统中常用的打包和解压命令,包括tar和zip,使用tar命令可以创建和解压tar格式的归档文件,使用zip命令可以创建和解压zip格式的压缩文件,每... 目录Lijavascriptnux 打包和解压命令打包命令解压命令总结linux 打包和解压命令打

Java中将异步调用转为同步的五种实现方法

《Java中将异步调用转为同步的五种实现方法》本文介绍了将异步调用转为同步阻塞模式的五种方法:wait/notify、ReentrantLock+Condition、Future、CountDownL... 目录异步与同步的核心区别方法一:使用wait/notify + synchronized代码示例关键

Python调用Orator ORM进行数据库操作

《Python调用OratorORM进行数据库操作》OratorORM是一个功能丰富且灵活的PythonORM库,旨在简化数据库操作,它支持多种数据库并提供了简洁且直观的API,下面我们就... 目录Orator ORM 主要特点安装使用示例总结Orator ORM 是一个功能丰富且灵活的 python O

Java调用DeepSeek API的最佳实践及详细代码示例

《Java调用DeepSeekAPI的最佳实践及详细代码示例》:本文主要介绍如何使用Java调用DeepSeekAPI,包括获取API密钥、添加HTTP客户端依赖、创建HTTP请求、处理响应、... 目录1. 获取API密钥2. 添加HTTP客户端依赖3. 创建HTTP请求4. 处理响应5. 错误处理6.

Deepseek R1模型本地化部署+API接口调用详细教程(释放AI生产力)

《DeepseekR1模型本地化部署+API接口调用详细教程(释放AI生产力)》本文介绍了本地部署DeepSeekR1模型和通过API调用将其集成到VSCode中的过程,作者详细步骤展示了如何下载和... 目录前言一、deepseek R1模型与chatGPT o1系列模型对比二、本地部署步骤1.安装oll

一分钟带你上手Python调用DeepSeek的API

《一分钟带你上手Python调用DeepSeek的API》最近DeepSeek非常火,作为一枚对前言技术非常关注的程序员来说,自然都想对接DeepSeek的API来体验一把,下面小编就来为大家介绍一下... 目录前言免费体验API-Key申请首次调用API基本概念最小单元推理模型智能体自定义界面总结前言最

JAVA调用Deepseek的api完成基本对话简单代码示例

《JAVA调用Deepseek的api完成基本对话简单代码示例》:本文主要介绍JAVA调用Deepseek的api完成基本对话的相关资料,文中详细讲解了如何获取DeepSeekAPI密钥、添加H... 获取API密钥首先,从DeepSeek平台获取API密钥,用于身份验证。添加HTTP客户端依赖使用Jav

redis防止短信恶意调用的实现

《redis防止短信恶意调用的实现》本文主要介绍了在场景登录或注册接口中使用短信验证码时遇到的恶意调用问题,并通过使用Redis分布式锁来解决,具有一定的参考价值,感兴趣的可以了解一下... 目录1.场景2.排查3.解决方案3.1 Redis锁实现3.2 方法调用1.场景登录或注册接口中,使用短信验证码场

使用C/C++调用libcurl调试消息的方式

《使用C/C++调用libcurl调试消息的方式》在使用C/C++调用libcurl进行HTTP请求时,有时我们需要查看请求的/应答消息的内容(包括请求头和请求体)以方便调试,libcurl提供了多种... 目录1. libcurl 调试工具简介2. 输出请求消息使用 CURLOPT_VERBOSE使用 C