乐筑天下

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

杂耍的属性。。

[复制链接]

46

主题

118

帖子

23

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
291
发表于 2008-4-3 09:51:39 | 显示全部楼层 |阅读模式
嗨,
我有一个标题块,其中包含7个可能的修订数据属性——REV1到REV7(以及7个可能的修订者首字母属性——REVBY1到REVBY7),当布局在第8次修订了7次时,当然没有更多的空间来添加最新的修订细节,所以我想以编程方式删除第一个实例REV1并“分流”列表中的所有其他人,为新细节在最后一个空间REV7中留下空间...
...所以当它正常工作时,REV1中的内容被删除并替换为REV2中的内容,那么REV3中的内容现在变成REV2等等等等...
>实现这一目标的最佳方法是什么?我是否需要循环遍历块的属性,将这些的文本字符串传递给字符串数组,然后再次循环并以我需要的方式将文本字符串替换为数组中的内容,然后将新细节放入REV7文本字符串中...
这个程序是我上传的使用“布局和列表框和其他L字...”线程的一部分我最近发布了(见下文的附加程序和测试图),已经完成,但想添加这一点来真正完善它...
我知道我的代码很不整洁,我做事的方式可能有点笨拙,但我相对较新这和我所知道的一切都是自学的,你们从碎片中扔给我,所以我道歉

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

18

主题

222

帖子

51

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
260
发表于 2008-4-3 10:06:09 | 显示全部楼层
我甚至不会把它放到数组中。我会把所有东西都放在一个字符串中,然后在需要时拆分字符串。
是的,你的方法就是我会这样做的方式
回复

使用道具 举报

46

主题

118

帖子

23

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
291
发表于 2008-4-3 10:32:27 | 显示全部楼层
好的,谢谢。那么我如何分割数组呢?我见过/听说过Split(),但你能简单地给我解释一下吗?是不是就像通过检查逗号来分隔逗号分隔的列表一样
另外,我不知道你是否检查过程序,但是当我点击程序的“全表”部分时,我已经在循环属性的循环中了,我还能在第一个主循环中再次循环属性吗(两次),或者程序会抛出一个spaz?
回复

使用道具 举报

18

主题

222

帖子

51

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
260
发表于 2008-4-3 10:45:03 | 显示全部楼层
是的,您可以根据需要多次嵌套循环
我会创建用唯一字符分隔的字符串,或者永远不会在实践中使用的字符串。
  1. mystring = mystring & myValue & "#:#"
这将将所有属性值连接在一起。然后当您需要取回值时
  1. dim MyVals as variant
  2. MyVals = split(MyString,"#:#",,vbTextCompare)
这将为您提供一个值数组,基于零
*oops*编辑以更正代码
回复

使用道具 举报

18

主题

222

帖子

51

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
260
发表于 2008-4-3 11:02:28 | 显示全部楼层
示例
  1. Dim MyString As String
  2. Dim X As Integer
  3.     For X = 0 To 10
  4.         MyString = MyString & X & "#:#"
  5.     Next X
  6. Dim MyValues As Variant
  7.     MyValues = Split(MyString, "#:#", , vbTextCompare)

MyString then=“0#:#1#:#2#:#:3#:4#::5#:#;6#:7#::#“
拆分后,它将变成
  1. MyValues(0) : "0"
  2. MyValues(1) : "1"
  3. MyValues(2) : "2"
  4. MyValues(3) : "3"
  5. MyValues(4) : "4"
  6. MyValues(5) : "5"
  7. MyValues(6) : "6"
  8. MyValues(7) : "7"
  9. MyValues(8) : "8"
  10. MyValues(9) : "9"
  11. MyValues(10) : "10"
  12. MyValues(11) : ""

回复

使用道具 举报

46

主题

118

帖子

23

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
291
发表于 2008-4-7 06:00:02 | 显示全部楼层
嗨,
我还没有尝试过分开,但是谢谢你的提醒,看起来这是一个很好的方法。我现在坚持使用字符串数组,但是一旦我对Split做了更多的研究,我将使用它..
无论哪种方式,我在循环块的属性时都有问题,但在相反的方向..
当然,您必须能够以相反的顺序循环属性(例如:从Ubound到Lbound)。我正在尝试,但在选择案例属性搜索(CountV)时出错。TagString行(请参见下面的代码),出现“下标超出范围”错误..
  1. Public Sub SHUNT_REVS()
  2. ' *******************************************************
  3. 'Loop through titleblock once to get attribute values..
  4. Dim EntSHUNT As AcadObject
  5. Dim AttribSHUNT As Variant
  6. Dim CountV as Integer
  7. Dim REV7shunt(0 To 6) As String
  8. Dim REVBY7shunt(0 To 6) As String
  9. For Each EntSHUNT In ThisDrawing.PaperSpace
  10.     If EntSHUNT.EntityName = "AcDbBlockReference" Then
  11.         AttribSHUNT = EntSHUNT.GetAttributes
  12.         For CountV = UBound(AttribSHUNT) To LBound(AttribSHUNT)
  13.             Select Case AttribSHUNT(CountV).TagString
  14.             Case "REVBY7"
  15.                 REVBY7shunt(6) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  16.                 AttribSHUNT(CountV).TextString = revBY ' Add newest detail to the 7th rev detail..
  17.             Case "REVBY6"
  18.                 REVBY7shunt(5) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  19.                 AttribSHUNT(CountV).TextString = REVBY7shunt(6)
  20.             Case "REVBY5"
  21.                 REVBY7shunt(4) = attribZ(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  22.                 attribZ(CountV).TextString = REVBY7shunt(5)
  23.             Case "REVBY4"
  24.                 REVBY7shunt(3) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  25.                 AttribSHUNT(CountV).TextString = REVBY7shunt(4)
  26.             Case "REVby3"
  27.                 REVBY7shunt(2) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  28.                 AttribSHUNT(CountV).TextString = REVBY7shunt(3)
  29.             Case "REVBY2"
  30.                 REV7shunt(1) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  31.                 AttribSHUNT(CountV).TextString = REVBY7shunt(2)
  32.             Case "REVBY1"
  33.                 REVBY7shunt(0) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  34.                 AttribSHUNT(CountV).TextString = REVBY7shunt(1)
  35.             Case "REV7"
  36.                 REV7shunt(6) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  37.                 AttribSHUNT(CountV).TextString = UCase(revnumber) & " - " & UCase(revdetails) & " - " & Date ' Add newest detail to the 7th rev detail..
  38.             Case "REV6"
  39.                 REV7shunt(5) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  40.                 AttribSHUNT(CountV).TextString = REV7shunt(6)
  41.             Case "REV5"
  42.                 REV7shunt(4) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  43.                 AttribSHUNT(CountV).TextString = REV7shunt(5)
  44.             Case "REV4"
  45.                 REV7shunt(3) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  46.                 AttribSHUNT(CountV).TextString = REV7shunt(4)
  47.             Case "REV3"
  48.                 REV7shunt(2) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  49.                 AttribSHUNT(CountV).TextString = REV7shunt(3)
  50.             Case "REV2"
  51.                 REV7shunt(1) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  52.                 AttribSHUNT(CountV).TextString = REV7shunt(2)
  53.             Case "REV1"
  54.                 REV7shunt(0) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
  55.                 AttribSHUNT(CountV).TextString = REV7shunt(1)
  56.             End Select
  57.         Next CountV
  58.     End If 'If entx is block..
  59. Next EntSHUNT
  60. End Sub

您认为可能会有什么问题吗?
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2008-4-7 08:23:46 | 显示全部楼层
我没有深入研究代码,但尝试一下…
  1. For CountV = UBound(AttribSHUNT) To LBound(AttribSHUNT) Step -1

回复

使用道具 举报

46

主题

118

帖子

23

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
291
发表于 2008-4-7 10:01:20 | 显示全部楼层
现在明白了,再次感谢基思,你真是我的救星
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-5 00:31 , Processed in 0.675985 second(s), 74 queries .

© 2020-2025 乐筑天下

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