乐筑天下

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

图纸集中的自定义道具

[复制链接]

12

主题

102

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
156
发表于 2008-2-26 06:41:26 | 显示全部楼层
标记,
插入一个新模块并将此代码粘贴到其中
这将要求您更改属性标题,为您提供现有值并允许您更改它
这是一个示例,向您展示其余部分是如何工作的
穆尔夫
  1. Dim aCount As Integer
  2. Dim cCount As Integer
  3. Dim eCount As Integer
  4. Dim iCount As Integer
  5. Dim mCount As Integer
  6. Dim pCount As Integer
  7. Dim sCount As Integer
  8. Dim pidCount As Integer
  9. Dim dwgCount As Integer
  10. Dim scl As String
  11. Dim chk As String
  12. Dim des As String
  13. Dim chrg As String
  14. Dim dwn As String
  15. Dim rinit As String
  16. Dim ssetName As String
  17. Dim ptitle As String
  18. Dim rdesc As String
  19. Dim rdate As String
  20. Dim rtype As String
  21. Dim dNum As String
  22. Dim draw As AcadDocument
  23. Dim newDir As String
  24. Dim newSelSet As IAcSmSheetSelSet
  25. Dim pstamp As String
  26. Dim pLines As String
  27. Dim tLines As String
  28. Dim donce As Boolean
  29. Dim wipeClean As Boolean
  30. Dim sdcCount As Integer
  31. Dim sdcChange As Boolean
  32. Dim NewSubsetStr As String
  33. Dim sdcCalled As Boolean
  34. Dim startDone As Boolean
  35. Dim sdcPrev As Boolean
  36. Dim repTxt As String
  37. Dim expSel As Boolean
  38. Dim xBook As Workbook
  39. Dim dSht As Worksheet
  40. Dim ppSht As Worksheet
  41. Dim ssSht As Worksheet
  42. Dim SingDrawComboPrev As Integer
  43. Public Sub SetProps()
  44. Dim i As Integer
  45. i = SheetSetsOpen
  46. If i > 1 Then
  47.     MsgBox "More than one Sheet Set are open. Make sure only one is open.", vbCritical
  48.     Exit Sub
  49. ElseIf i = 0 Then
  50.     MsgBox "No Sheet Set is open. Make sure one is open.", vbCritical
  51.     Exit Sub
  52. End If
  53.     Dim ssm As New AcSmSheetSetMgr
  54.     Dim dbIter As IAcSmEnumDatabase
  55.     Dim db As IAcSmDatabase
  56.     Dim ss As AcSmSheetSet
  57.     If ssm Is Nothing Then
  58.         MsgBox "Something wrong here: 1", vbCritical
  59.         Exit Sub
  60.     End If
  61.     Set dbIter = ssm.GetDatabaseEnumerator
  62.     If dbIter Is Nothing Then
  63.         MsgBox "Something wrong here: 2", vbCritical
  64.         Exit Sub
  65.     End If
  66.     dbIter.Reset
  67.     'get the Database of the first sheetset
  68.     Set db = dbIter.Next
  69.     If db Is Nothing Then
  70.         MsgBox "No Sheet Set open", vbCritical
  71.         Exit Sub
  72.     End If
  73.     'get the sheetset
  74.     Set ss = db.GetSheetSet
  75.     If ss Is Nothing Then
  76.         MsgBox "Cannot get the Sheet Set", vbCritical
  77.         Exit Sub
  78.     End If
  79.     Set oSheetIter = ss.GetSheetEnumerator
  80.     If oSheetIter Is Nothing Then
  81.       Return
  82.     End If
  83.     'lock the database
  84.     Dim lockStatus As AcSmLockStatus
  85.     Let lockStatus = db.GetLockStatus
  86.     If lockStatus = AcSmLockStatus_UnLocked Then
  87.       db.LockDb db
  88.     Else
  89.         Dim sUserName As String
  90.         Dim sMachineName As String
  91.         db.GetLockOwnerInfo sUserName, sMachineName
  92.         MsgBox "The Sheet Set is locked by " & sUserName & " at " & sMachineName, vbCritical
  93.         Exit Sub
  94.     End If
  95.     Dim compEnum As IAcSmEnumComponent
  96.     'get component enumerator
  97.     Set compEnum = ss.GetSheetEnumerator
  98.         Call LoopThroughSheetsSetMark(compEnum)
  99.     'unlock the database
  100.     Call db.UnlockDb(db, True)
  101. End Sub
  102. Private Sub LoopThroughSheetsSetMark(ByVal compEnum As IAcSmEnumComponent)
  103.     Dim comp As IAcSmComponent
  104.     Dim lastrevn As Variant
  105.     Dim lyOut As AcSmAcDbLayoutReference
  106.     Dim lyName As String
  107.     Dim lastrevd As String
  108.     Dim lastrevdate As String
  109.     Dim rNumTemp As String
  110.     Dim rnNext As String
  111.     Dim rnVar As Variant
  112.     Dim dirmade As Boolean
  113.     Dim tLine1 As String
  114.     Dim tLine2 As String
  115.     Dim tLine3 As String
  116.     Dim selsets As AcSmSheetSelSets
  117.     Dim selset As AcSmSheetSelSet
  118.     Dim tselset As AcSmSheetSelSet
  119.     Dim ssMade As Boolean
  120.     Dim ttitle As String
  121.     Dim repTemp As String
  122. Dim cssProp As String
  123. Dim exstVal As String
  124. Dim newVal As String
  125.     On Error GoTo ErrHandler
  126.     ssMade = False
  127.     Set comp = compEnum.Next()
  128.     dirmade = False
  129.     cssProp = InputBox("What is the EXACT title of your custom property?", "Property Title")
  130.     ' loop through till the component is Nothing
  131.     Do While Not comp Is Nothing
  132.         'if the component is a sheet, then...
  133.         If comp.GetTypeName = "AcSmSheet" Then
  134.             Dim s As AcSmSheet
  135.             Set s = comp
  136.             Dim sNumber As String
  137.             Dim sTitle As String
  138.             exstVal = GetCSSProperties(cssProp, s)
  139.             sTitle = s.GetTitle
  140.             
  141.             newVal = InputBox("The drawing " & sTitle & vbCr & "has a value of" & vbCr & exstVal & vbCr & _
  142.             "for the Custom Property titled" & vbCr & cssProp & vbCr & vbCr & "Please enter the new value here. Leave blank for no change" _
  143.             , "Properties to the Extreme")
  144.             
  145.             If Not newVal = "" Then
  146.                 ChangeProperties cssProp, newVal, s
  147.             End If
  148.          
  149.     ElseIf comp.GetTypeName = "AcSmSubset" Then
  150.             Dim sset As AcSmSubset
  151.             Set sset = comp
  152.             'loop through all the sheets.
  153.             Call LoopThroughSheetsSet(sset.GetSheetEnumerator)
  154.         End If
  155.         'next
  156.         Set comp = compEnum.Next()
  157.     Loop
  158.     GoTo Exit_Here
  159. ErrHandler:
  160. Select Case Err.Number
  161.     Case -2147467259
  162.         Err.Clear
  163.         Resume
  164.     Case Else
  165.         MsgBox Err.Number & ":" & Err.Description, vbOKOnly, "Error " & Err.Number
  166.         GoTo Exit_Here
  167. End Select
  168. Exit_Here:
  169. End Sub
回复

使用道具 举报

12

主题

102

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
156
发表于 2008-2-26 10:10:10 | 显示全部楼层

嘿Murph我真的很感激;我一直在进步,但进展很慢
这东西不是很直观
好的,我把代码复制到一个新模块中;我仍然是de进入新模块;但我还是有一些错误
我做的第一件事就是把你必须擅长的任何参考文献都注释掉;现在
另一件事是,这个代码
  1. i = SheetSetsOpen
  2. If i > 1 Then
  3.     MsgBox "More than one Sheet Set are open. Make sure only one is open.", vbCritical
  4.     Exit Sub
  5. ElseIf i = 0 Then
  6.      MsgBox "No Sheet Set is open. Make sure one is open.", vbCritical
  7.      Exit Sub
  8. End If
它告诉我,实际上没有打开的图纸集;所以我把它注释掉了
我可能做错了什么,但我打开了图纸集管理器并加载了一个图纸集,我使用的是CAD附带的示例(civil),我打开并激活了一个布局
另外,我现在看到sUserName、SmacheName是数据库GetLockOwnerInfo方法的一部分
有了这个,我一直得到一个错误,那就是我在我的机器上锁定了图纸集
那么,我们是否过早地锁定了板材放置
还有,我们是否缺少一个函数:
再次感谢您为我破解代码;这使得它更加全面
I'我只是不太清楚为什么我们会犯这样的错误
标记
回复

使用道具 举报

12

主题

102

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
156
发表于 2008-2-26 10:31:32 | 显示全部楼层
标记,
GetCSSProperties应该包含在我链接到的dvb中。
您可以在设置I=SheetSetsOpen的地方停止代码,并检查我的值吗
您正在运行什么版本/风格的Autocad
关于被锁定的图纸集,如果您一直在使用同一个图纸集进行测试,那么它可能仍然会从上次出错时起被锁定
查找并运行SheetSetSheet。现在解锁,然后运行我之前给你的东西
告诉我接下来会发生什么
Murph
回复

使用道具 举报

12

主题

102

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
156
发表于 2008-2-26 10:36:30 | 显示全部楼层

嘿,Murph,我需要得到这个函数,然后把它粘贴到代码的其余部分下面,对吗
我逐步完成了代码,返回0。我正在使用Land Desktop 2006。此外,我只是创建了一个单独的模块来解锁数据库
有什么建议吗
谢谢
标记
回复

使用道具 举报

12

主题

102

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
156
发表于 2008-2-26 10:56:30 | 显示全部楼层

好的,Murph,我从你的另一个项目中复制了3个函数:GetCSSProperties,ChangeProperties+,LoopThroughSheets(末尾有标记),现在,它正在工作;我现在收到输入框的提示,没有任何错误
现在,我需要弄清楚在每个输入框中输入什么
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-5 08:52 , Processed in 0.317607 second(s), 61 queries .

© 2020-2025 乐筑天下

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