乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 34|回复: 1

[编程交流] [HELP] How to get attributes

[复制链接]

4

主题

6

帖子

13

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 17:06:31 | 显示全部楼层 |阅读模式
Hi frnds,
 
I have a dwg file which contains thousands of blockrefrence type objects
 
What i want is.....
 
for each block(block refrence type) in thedrawing
get its layer name
get is block name
nd get its block attributes
next
 
all this should be exported in the excel file
 
I have coded but it seems i m not getting the thing i want
 
  1. Public Sub ChTitle_click()Dim acadOBJ As AcadObjectDim oEnt As AcadEntityDim oAtt As AcadAttributeReferenceDim varAtts As VariantDim varName As VariantDim varLayer As VariantDim varSwitchGearNo As VariantDim i, j, z As Integeri = j = 0'connect to excelDim oExcel As Excel.ApplicationDim oBook As Excel.WorkbookDim oSheet As Excel.WorksheetDim nRow As Integer'Open ExcelSet oExcel = New Excel.ApplicationoExcel.Visible = True'Set oBook = oExcel.Workbooks.Add("C:\trial.xls")  ' OptionalSet oBook = oExcel.Workbooks.Add()Set oSheet = oBook.Sheets("Sheet1")'  With oSheetoSheet.Cells(1, 1).Borders.LineStyle = xlContinuousoSheet.Cells(1, 1).Font.Bold = TrueoSheet.Cells(1, 1) = "FEEDER ID"oSheet.Cells(1, 2).Borders.LineStyle = xlContinuousoSheet.Cells(1, 2).Font.Bold = TrueoSheet.Cells(1, 2) = "SwitchGear Type"oSheet.Cells(1, 3).Borders.LineStyle = xlContinuousoSheet.Cells(1, 3).Font.Bold = TrueoSheet.Cells(1, 3) = "SwitchGear No"'Variable declarationDim nStartwriting As IntegernStartwriting = 2'For Each oEnt In ThisDrawing.ModelSpaceFor Each oEnt In ThisDrawing.ModelSpace   If TypeName(oEnt) = "IAcadBlockReference" Then       oSheet.Cells(nStartwriting, 1) = oEnt.Layer       oSheet.Cells(nStartwriting, 2) = oEnt.Name       If oEnt.HasAttributes Then           varAtts = oEnt.GetAttributes           For i = 0 To UBound(varAtts)               ReDim varSwitchGearNo(j) As Variant               oSheet.Cells(nStartwriting, 3) = varAtts(i).TextString'                varSwitchGearNo(j) = varAtts(i).TextString               j = j + 1           Next i       End If       nStartwriting = nStartwriting + 1   End IfNextCall oBook.Close(True, "C:" & "SLD" & ".xls")oExcel.DisplayAlerts = FalseoExcel.QuitEnd Sub
 
Anyone, what i m doing wrong
回复

使用道具 举报

0

主题

132

帖子

198

银币

限制会员

铜币
-21
发表于 2022-7-6 18:41:26 | 显示全部楼层
Rather than trying to figure it out, what exactly does it do? Does it fail? Does it put in wrong info? A little more specific please.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-5-28 01:57 , Processed in 3.677102 second(s), 57 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表