简介

在windows下台下, 使用comtypes库, 通过ActiveX操作autocad, 从而读取AutoCAD数据

  • comtypes.client

AutoCAD ActiveX

  • GetActiveObject('AutoCAD.Application')
  • Document
  • ModelSpace

1. 得到AutoCAD对象

import comtypes.client
# 得到AutoCAD应用程序对象
acad = comtypes.client.GetActiveObject('AutoCAD.Application')
# 得到当前文档
doc = acad.ActiveDocument
# 得到当前文档模型空间
model_space = doc.ModelSpace

2. 创建2维多义线(LightWeightPolyline)

import array
points = array.array('d', range(10))
acad.ActiveDocument.ModelSpace.AddLightWeightPolyline(points)

3. 读取2维多义线(LightWeightPolyline)

apline = comtypes.client.GetBestInterface(apline)
print(apline.Coordinates)

4. 添加多义线完整的例子

#!/usr/bin/env python
# -*- coding:utf-8 -*- # 导入标准库
import comtypes.client
import array # 得到AutoCAD应用程序对象
acad = comtypes.client.GetActiveObject('AutoCAD.Application')
# 得到当前文档
doc = acad.ActiveDocument
# 得到当前文档模型空间
model_space = doc.ModelSpace # 生成多义线点
points = array.array('d', range(10))
# 添加多义线
model_space.AddLightWeightPolyline(points)

Windows下Python + AutoCAD 多义线绘图小结的更多相关文章

  1. Windows下python的配置

    Windows下python的配置 希望这是最后一次写关于python的配置博客了,已经被python的安装烦的不行了.一开始我希望安装python.手动配置pip并使用pip安装numpy,然而发现 ...

  2. windows下python web开发环境的搭建

    windows下python web开发环境: python2.7,django1.5.1,eclipse4.3.2,pydev3.4.1 一. python环境安装 https://www.pyth ...

  3. Windows下Python读取GRIB数据

    之前写了一篇<基于Python的GRIB数据可视化>的文章,好多博友在评论里问我Windows系统下如何读取GRIB数据,在这里我做一下说明. 一.在Windows下Python为什么无法 ...

  4. [转]Windows下Python多版本共存

    https://blog.csdn.net/dream_an/article/details/51248736 Windows下Python多版本共存 Python数据科学安装Numby,pandas ...

  5. Windows下Python安装numpy+mkl,Scipy和statsmodels

    最近做时间序列分析需要用到Python中的statsmodels,但是安装过程中遇到很头疼的问题,Google.Stackover各种都没有找到合适的解决办法,而且貌似还有很多同学也在吐槽Window ...

  6. windows下python检查文件是否被其它文件打开

    windows下python检查文件是否被其它文件打开.md 有时候我们需要能够判断一个文件是否正在被其它文件访问,几乎不可避免的要调用操作系统接口 from ctypes import cdll i ...

  7. python学习:Windows 下 Python easy_install 的安装

    Windows 下 Python easy_install 的安装     下载安装python安装工具下载地址:http://pypi.python.org/pypi/setuptools 可以找到 ...

  8. windows下python安装Numpy、Scipy、matplotlib模块(转载)

    python下载链接     Numpy下载链接 python中Numpy包的安装及使用 Numpy包的安装 准备工作 Python安装 pip安装 将pip所在的文件夹添加到环境变量path路径中 ...

  9. 最实用windows 下python+numpy安装(转载)

    最实用windows 下python+numpy安装 如题,今天兜兜转转找了很多网站帖子,一个个环节击破,最后装好费了不少时间. 希望这个帖子能帮助有需要的人,教你一篇帖子搞定python+numpy ...

随机推荐

  1. Eclipse Rap开发 异步刷新UI处理

    1.Display.getCurrent()获取的是当前线程的display对象,如果当前在非UI线程中那么获取到的display对象为空:      一般Display.getCurrent() 用 ...

  2. C#中SetWindowPos函数详解

    [DllImport("user32.dll")] private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWnd ...

  3. Deutsch lernen (06)

    1. das Verzeichnis,-se 表格:名单,目录 Die Daten sind in einem Verzeichnis enthalten. (包括,含有) 2. enthalten  ...

  4. SAP computer之input and MAR

    Input and MAR Below the program counter is the input and MAR block. It includes the address and data ...

  5. bzoj 4994: [Usaco2017 Feb]Why Did the Cow Cross the Road III 树状数组_排序

    Description 给定长度为2N的序列,1~N各处现过2次,i第一次出现位置记为ai,第二次记为bi,求满足ai<aj<bi<bj的对数 题解: 方法一: 搞一个KDtree, ...

  6. MessageFormat.format()用法

    1.java.text.Format的继承结构如下   2.MessageFormat模式 FormatElement { ArgumentIndex }:是从0开始的入参位置索引 { Argumen ...

  7. PHP学习总结(14)——PHP入门篇之常用运算符

    一.什么是运算符 什么是运算符?运算符是告诉PHP做相关运算的标识符号.例如,你需要计算123乘以456等于多少,这时候就需要一个符号,告诉服务器,你需要做乘法运算. PHP中的运算符有哪些?PHP运 ...

  8. (13)处理静态资源(默认资源映射)【从零开始学Spring Boot】

    Spring Boot 默认为我们提供了静态资源处理,使用 WebMvcAutoConfiguration 中的配置各种属性. 建议大家使用Spring Boot的默认配置方式,如果需要特殊处理的再通 ...

  9. MySQL:浅析 Impossible WHERE noticed after reading const tables

    使用 EXPLAIN 执行计划的时候,在 Extra 中偶尔会看到这样的描述: Impossible WHERE noticed after reading const tables 字面上的意思是: ...

  10. 0120Keeplived实现自动切换Mysql服务

    转自http://biancheng.dnbcw.info/mysql/381020.html Keepalived+mysql 自动切换网络结构:VIP 192.168.88.200mysq11 1 ...