当前位置: 首页 > news >正文

c# 获取CAD已加载的线型 并且在对话框的下拉列表显示出来

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 图书管理登录界面WPF.Service
{
public class LineStyleInfo
{
public ObjectId id { get; set; }
public string lineTypename { get; set; }
}

public class GetLineType
{/// <summary>/// 获取线型/// </summary>/// <returns></returns>public static List<LineStyleInfo> GetLinetype(){Document doc = Application.DocumentManager.MdiActiveDocument;Database db = doc?.Database;Editor ed = doc?.Editor;using (Transaction trans = db.TransactionManager.StartTransaction()){List<LineStyleInfo> lineTypeInfo = new List<LineStyleInfo>();try{if (doc == null) return (lineTypeInfo);LinetypeTable linetypeT = trans.GetObject(db.LinetypeTableId, OpenMode.ForRead) as LinetypeTable;foreach (ObjectId item in linetypeT){LinetypeTableRecord LineTypeRecordName = trans.GetObject(item, OpenMode.ForRead) as LinetypeTableRecord;lineTypeInfo.Add(new LineStyleInfo{id = item,lineTypename = LineTypeRecordName.Name});}trans.Commit();}catch (Exception ex){Debug.WriteLine(ex.Message);}return (lineTypeInfo);}}
}

}

using Autodesk.AutoCAD.DatabaseServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 图书管理登录界面WPF.Service;

namespace 图书管理登录界面WPF.Mode
{
public class LineTypeData
{
public List DataLineTableR { get; }
public LineTypeData()
{
List LineTypeTableR = GetLineType.GetLinetype();
DataLineTableR = LineTypeTableR;
}
}
}

using Autodesk.AutoCAD.DatabaseServices;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using 图书管理登录界面WPF.Mode;
using 图书管理登录界面WPF.Service;

namespace 图书管理登录界面WPF.ViewMode
{
public class LineTypes:INotifyPropertyChanged
{
LineTypeData lineTypeData;
public LineTypes()
{
lineTypeData=new LineTypeData();
LineTypeList = new ObservableCollection (lineTypeData.DataLineTableR);
LineTypeCount = LineTypeList.Count;

        // 可选:默认选中第一个if (LineTypeList.Any()){SelectlineType = LineTypeList.First().id.ToString();SelectedLineTypeName = LineTypeList.First().lineTypename;}}private ObservableCollection<LineStyleInfo> _lineTypeList; //保留完整的数据结构private string _selectlineType;public string SelectedLineTypeName { get; set; }public int LineTypeCount { get; set; }public ObservableCollection <LineStyleInfo> LineTypeList{get => _lineTypeList;set { _lineTypeList = value;OnPropertyChanged();} }public  string SelectlineType {get => _selectlineType;set{_selectlineType = value;OnPropertyChanged();}}public event PropertyChangedEventHandler PropertyChanged;private void OnPropertyChanged([CallerMemberName] string PropertyName = null) =>PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName));
}

}

    <ComboBox ItemsSource="{Binding LineTypeList}" DisplayMemberPath="lineTypename" SelectedValuePath="id"  VerticalAlignment="Center" SelectedValue="{Binding SelectlineType}" FontSize="20"  Height="50" Width="300" Background="Red"/><TextBox Height="50" Width="300" Margin="0,150,0,0" FontSize="15" Text="{Binding SelectlineType}"/>
</Grid>
http://www.jsqmd.com/news/668964/

相关文章:

  • 从STRIDE到EVITA:聊聊车载网络威胁建模中,那个更适合你的安全属性模型
  • 告别龟速下载!Hugging Face预训练模型(BERT/RoBERTa)手动下载与本地加载保姆级教程
  • 贵阳找工作必看:2026年销售岗位大盘点,为什么AI营销和顾问型销售更值得选? - 精选优质企业推荐官
  • 解决VisualStudio2026中文打印报错或者乱码
  • UE4/UE5委托实战避坑:从触发器交互到UI响应,手把手教你四种委托的正确用法
  • 如何快速使用MCA Selector:Minecraft世界编辑完整指南
  • 基于springboot的摄影作品分享活动参与网站
  • Ostrakon-VL像素终端部署:离线环境无网络依赖运行方案
  • OCR数据集哪家强?ICDAR/CTW/Total-Text等8大主流数据集实战评测与下载指北
  • Untrunc终极指南:三步修复损坏MP4/MOV视频的完整教程
  • 【卷卷观察】Vibe Coding 时代:有些人已经在用 AI 写代码,有些人还在争论 AI 能不能写代码
  • Vibe Coding 完全实战手册:2026年 AI 辅助编程工作流从入门到精通
  • 基于springboot的新农村自建房改造管理系统
  • YOLO目标检测专用数据集:盲道识别与多类障碍物检测(16类别,9000张标注图)
  • 正则表达式 - 修饰符
  • SITS2026基准套件发布,立即获取首批28家头部实验室实测数据对比表,含GPT-5、Claude-4、Qwen-Max等6大模型得分详情
  • CLIP模型背后的秘密:为什么InfoNCE损失成为自监督学习的标配?
  • 别再让视频裸奔了!手把手教你用PolyV思路给m3u8视频上三道锁(含动态Key实战)
  • Day03:ReAct架构概述:从_军师_到_将军_的进化
  • CLAUDE.md:90%人用错了
  • 别再手动折腾了!用Stellar Repair for MS SQL 10.0自动化处理‘可疑’数据库状态
  • 别光刷题!AcWing语法基础课的正确打开方式:我是如何用‘变量-输入输出-表达式’这三板斧搞定编程思维的
  • 别急着改代码!先检查这几点:CUDA nvcc编译失败常见原因与Detectron2避坑指南
  • 告别拖拽画布:用ABAP Dialog Screen手搓一个订单管理界面(附完整代码)
  • python terrascan
  • 嵌入式GUI框架怎么选?从LVGL、TouchGFX到AWTK,5分钟帮你理清思路
  • 深度剖析成都奥迪 A6L 的 AP 卡钳升级之路
  • 技术人如何从肯尼迪就职演说中学习高效沟通与演讲技巧(附英文原文精读)
  • 为什么大家都说嘎嘎降AI好用?深度解读降AI率工具好坏的本质
  • C语言复试别慌!这15个高频考点和易错点,帮你稳住面试官