欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python使用pyautocad+openpyxl處理cad文件示例

 更新時(shí)間:2019年07月11日 09:28:51   作者:mengtianwxs  
這篇文章主要介紹了Python使用pyautocad+openpyxl處理cad文件,結(jié)合實(shí)例形式分析了Python使用pyautocad與openpyxl模塊讀寫cad文件相關(guān)應(yīng)用操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Python使用pyautocad+openpyxl處理cad文件。分享給大家供大家參考,具體如下:

示例1:

from pyautocad import Autocad
import openpyxl
wb=openpyxl.load_workbook('./cads.xlsx')
sheet=wb.get_sheet_by_name('Sheet1')
data=[]
pset=[]
acad=Autocad(create_if_not_exists=True)
acad.prompt('hello this is python in')
for text in acad.iter_objects('Text'):
 data.append(text.TextString)
from pyautocad import APoint
for text in acad.iter_objects('Text'):
 pset.append(APoint(text.InsertionPoint))
print len(data)
for d in range(1,len(data)):
 sheet['A'+str(d)].value=data[d]
 sheet['B'+str(d)].value=str(pset[d].x)
 sheet['C'+str(d)].value=str(pset[d].y)
wb.save('aabb1.xlsx')
print 'success aabb1.xlsx'

其實(shí)pyautocad中有關(guān)于table的api

示例2:

from pyautocad import Autocad
import openpyxl
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
wb=openpyxl.load_workbook('./aabb.xlsx')
sheet=wb.get_sheet_by_name('Sheet1')
data=[]
acad=Autocad(create_if_not_exists=True)
acad.prompt('hello this is python in')
for text in acad.iter_objects('Text'):
 data.append(text.TextString)
print len(data)
for d in range(1,len(data)):
 if(str(data[d])[0:4]=="BM30" or str(data[d])[0:4]=="BM65"):
  sheet['A'+str(d)].value=data[d]
wb.save('ky1.xlsx')
print 'success ky1.xlsx'

截取了BM30和BM65的數(shù)據(jù)

示例3:

import openpyxl
from pyautocad import Autocad,APoint
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
wb=openpyxl.load_workbook("a.xlsx")
sheet=wb.get_sheet_by_name("Sheet1")
data=[]
px=[]
py=[]
acad=Autocad(create_if_not_exists=True)
acad.prompt("hello this is mt")
for text in acad.iter_objects('Text'):
  data.append(text.TextString)
  #print text.TextString
  px.append(APoint(text.InsertionPoint).x)
  py.append(APoint(text.InsertionPoint).y)
  #print text.InsertionPoint
print len(data)
print "eof"
for d in range(1,len(data)):
  if(str(data[d])[0:4]=="Vigi" or str(data[d])[0:4]=="iC65" or str(data[d])[0:3]=="CVS" or str(data[d])[0:3]=="PRD" or str(data[d])[0:4]=="DDZY"):
    sheet['A'+str(d)]=data[d]
    sheet['B'+str(d)]=px[d]
    sheet["C"+str(d)]=py[d]
   #  print data[d]
wb.save("kv.xlsx")
print "success"
#or str(data[d])[0:3]=="CVS" or str(data[d])[0:3]=="PRD" or str(data[d])[0:4]=="DDZY"

更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Python文件與目錄操作技巧匯總》、《Python文本文件操作技巧匯總》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》及《Python入門與進(jìn)階經(jīng)典教程

希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • Python3實(shí)現(xiàn)的Mysql數(shù)據(jù)庫(kù)操作封裝類

    Python3實(shí)現(xiàn)的Mysql數(shù)據(jù)庫(kù)操作封裝類

    這篇文章主要介紹了Python3實(shí)現(xiàn)的Mysql數(shù)據(jù)庫(kù)操作封裝類,涉及Python針對(duì)mysql數(shù)據(jù)庫(kù)的連接、查詢、更新及關(guān)閉連接等相關(guān)操作技巧,需要的朋友可以參考下
    2018-06-06
  • python遍歷序列enumerate函數(shù)淺析

    python遍歷序列enumerate函數(shù)淺析

    enumerate函數(shù)用于遍歷序列中的元素以及它們的下標(biāo)。下面通過本文給大家分享python遍歷序列enumerate函數(shù)淺析,需要的朋友參考下吧
    2017-10-10
  • 淺談tensorflow中Dataset圖片的批量讀取及維度的操作詳解

    淺談tensorflow中Dataset圖片的批量讀取及維度的操作詳解

    今天小編就為大家分享一篇淺談tensorflow中Dataset圖片的批量讀取及維度的操作詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-01-01
  • 在Python 字典中一鍵對(duì)應(yīng)多個(gè)值的實(shí)例

    在Python 字典中一鍵對(duì)應(yīng)多個(gè)值的實(shí)例

    今天小編就為大家分享一篇在Python 字典中一鍵對(duì)應(yīng)多個(gè)值的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-02-02
  • python3.7調(diào)試的實(shí)例方法

    python3.7調(diào)試的實(shí)例方法

    在本篇文章里小編給大家整理的是一篇關(guān)于python3.7調(diào)試的實(shí)例方法,需要的朋友可以學(xué)習(xí)下。
    2020-07-07
  • 用Python實(shí)現(xiàn)局域網(wǎng)控制電腦

    用Python實(shí)現(xiàn)局域網(wǎng)控制電腦

    大家好,本篇文章主要講的是用Python實(shí)現(xiàn)局域網(wǎng)控制電腦,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下
    2022-01-01
  • Python實(shí)現(xiàn)截屏的函數(shù)

    Python實(shí)現(xiàn)截屏的函數(shù)

    這篇文章主要介紹了Python實(shí)現(xiàn)截屏的函數(shù),可實(shí)現(xiàn)Python針對(duì)屏幕的截屏功能,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下
    2015-07-07
  • 使用Python判斷一個(gè)文件是否被占用的方法教程

    使用Python判斷一個(gè)文件是否被占用的方法教程

    這篇文章主要給大家介紹了關(guān)于如何使用Python判斷一個(gè)文件是否被占用的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • python之json文件轉(zhuǎn)xml文件案例講解

    python之json文件轉(zhuǎn)xml文件案例講解

    這篇文章主要介紹了python之json文件轉(zhuǎn)xml文件案例講解,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • python 提高開發(fā)效率的5個(gè)小技巧

    python 提高開發(fā)效率的5個(gè)小技巧

    這篇文章主要介紹了python 提高開發(fā)效率的5個(gè)小技巧,幫助大家更好的進(jìn)行python開發(fā),感興趣的朋友可以了解下
    2020-10-10

最新評(píng)論