005集—— 用户交互之CAD窗口选择图元实体(CAD—C#二次开发入门)

ops/2024/10/11 10:54:18/

 如下图:根据提示选择若干图形要素,空格或右键结束选择,返回图元的objectid,以便进一步操作图元实体。

 代码如下:

using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using System.Collections.Generic;
using Autodesk.AutoCAD.ApplicationServices;
namespace sc
{public class Class1{public static ObjectId GetEntity(string message){Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;PromptEntityOptions po = new PromptEntityOptions(message);PromptEntityResult pr = ed.GetEntity(po);return pr.ObjectId;}public static List<ObjectId> SelectEntities(string message){Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;List<ObjectId> objectIds = new List<ObjectId>();PromptSelectionOptions pso = new PromptSelectionOptions();pso.AllowDuplicates  = true; // 允许用户选择多个实体  //pso.UsePickset = true;    // 使用Pickset模式,这样可以返回用户选择的所有实体  PromptSelectionResult psr = ed.GetSelection(pso);if (psr.Status == PromptStatus.OK){SelectionSet selectionSet = psr.Value;foreach (SelectedObject selectedObj in selectionSet){objectIds.Add(selectedObj.ObjectId);}}return objectIds;}[CommandMethod("xx")]public void Msc(){List<ObjectId> objectIds = SelectEntities("请选择若干实体:");Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;try{foreach (ObjectId id in objectIds){ed.WriteMessage($"\nObjectId: {id}");}}catch (System.Exception ex){ed.WriteMessage($"\n错误: {ex.Message}");}}}
}

 


http://www.ppmy.cn/ops/123950.html

相关文章

Docker 的数据管理

一、容器中数据管理 管理 Docker 容器中数据主要有两种方式&#xff1a;数据卷&#xff08;Data Volumes&#xff09;和数据卷容器&#xff08;DataVolumes Containers&#xff09;。 1&#xff0e;数据卷 数据卷是一个供容器使用的特殊目录&#xff0c;同时数据卷是宿主机中的…

如何看待诺贝尔物理学奖颁给了机器学习与神经网络?

近日&#xff0c;2024年诺贝尔物理学奖颁发给了机器学习与神经网络领域的研究者&#xff0c;这是历史上首次出现这样的情况。这项奖项原本只授予对自然现象和物质的物理学研究作出重大贡献的科学家&#xff0c;如今却将全球范围内对机器学习和神经网络的研究和开发作为了一种能…

mysql linux 安装

--------------------------------------------------------------------------------------------------------------------------------- 1.前置准备 1.1 卸载旧版MySQL 1.2 查看rpm包 rpm -qa|grep mysql 若有可用 rpm -e 安装包 --nodeps 1.3 查找mysql残留包&#x…

WMS系统拣货管理的优化与创新

一、WMS系统拣货管理的重要性 随着电子商务的快速发展&#xff0c;物流仓储行业面临着巨大的挑战。订单量的激增导致传统的手工拣货方式难以满足需求&#xff0c;而WMS系统的引入则解决了这一问题。通过WMS系统&#xff0c;仓库可以实现自动化、智能化的拣货管理&#xff0c;大…

RabbitMQ(学习前言)

目录 学习MQ之前有必要先去温故下微服务知识体系&#xff0c;以加深本章节的理解 一、微服务间的通讯方式 1. 基本介绍 2. 同步通讯 2.1. 什么是同步通讯 2.2. 同步通讯存在的问题 问题一&#xff1a;耦合度高 问题二&#xff1a;性能和吞吐能力下降 问题三&#xff1a…

第 2 章 基础支持层(上)

2.1 解析器模块 常见的 XML 处理方式 DOM&#xff0c;基于树形结构的 XML 解析方式&#xff0c;它会将整个 XML 文档读入内存并构建一个 DOM 树&#xff0c;基于这棵树形结构对各个节点&#xff08;Node&#xff09;进行操作。 SAX&#xff0c;基于事件模型的 XML 解析方式&a…

[Meachines] [Easy] Sea WonderCMS-XSS-RCE+System Monitor 命令注入

信息收集 IP AddressOpening Ports10.10.11.28TCP:22&#xff0c;80 $ nmap -p- 10.10.11.28 --min-rate 1000 -sC -sV PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 3072 e3:54:…

LangChain从模型中提取json输出

1.导包 from typing import Listfrom langchain.output_parsers import PydanticOutputParser from langchain.prompts import ChatPromptTemplate from langchain.schema import HumanMessage from langchain_core.pydantic_v1 import BaseModel, Field from langchain_opena…