马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
困惑许久,今日豁然
不敢独珍,与诸君分享
From maxd
Can anyone tell me how I can list the names of all the dictionaries attached to
the ActiveDocument. I am using VB6 and AutoCad 2000. The code line below gives
me a type mismatch.
- Set objDictionary = objAcad.ActiveDocument.Dictionaries.Item(i)
复制代码
-------------------------------------------------------------------------------
Hey there maxd -
The Dictionaries object doesn't contain just Dictionary objects as the help
file, or even this code,
- Public Sub TheLIE()
- Dim objLibrary As AcadDictionaries
- Dim intCnt As Integer
- Set objLibrary = ThisDrawing.Dictionaries
- For intCnt = 0 To objLibrary.Count - 1
- Debug.Print objLibrary(intCnt).ObjectName
- Next intCnt
- End
- 'Results from a new drawing:
- 'AcDbDictionary
- 'AcDbDictionary
- 'AcDbDictionary
- 'AcDbDictionary
- 'AcDbDictionaryWithDefault
suggests!
Here is the truth:
- Public Sub TheTruth()
- Dim objLibrary As AcadDictionaries
- Dim intCnt As Integer
- Set objLibrary = ThisDrawing.Dictionaries
- For intCnt = 0 To objLibrary.Count - 1
- Debug.Print TypeName(objLibrary(intCnt))
- Next intCnt
- End
- 'Results in same drawing:
- 'IAcadGroups
- 'IAcadLayouts
- 'IAcadDictionary
- 'IAcadPlotConfigurations
- 'IAcadDictionary
AHA! Now, an example of how to work with what's really in there:
- Public Sub CheckOut()
- Dim objLibrary As AcadDictionaries
- Dim objDictionary As AcadDictionary
- Dim objLayOuts As AcadLayouts
- Dim objGroups As AcadGroups
- Dim objPlots As AcadPlotConfigurations
- Dim objEach As Object
- Dim intCnt As Integer
- Set objLibrary = ThisDrawing.Dictionaries
- For intCnt = 0 To objLibrary.Count - 1
- Select Case TypeName(objLibrary(intCnt))
- Case "IAcadGroups"
- Set objGroups = objLibrary(intCnt)
- For Each objEach In objGroups
- Debug.Print objEach.Name
- Next objEach
- Case "IAcadLayouts"
- Set objLayOuts = objLibrary(intCnt)
- For Each objEach In objLayOuts
- Debug.Print objEach.Name
- Next objEach
- Case "IAcadDictionary"
- Set objDictionary = objLibrary(intCnt)
- Debug.Print objDictionary.Name
- Case "IAcadPlotConfigurations"
- Set objPlots = objLibrary(intCnt)
- For Each objEach In objPlots
- Debug.Print objEach.Name
- Next objEach
- Case Else
- Debug.Print "VODKA MARTINI"
- End Select
- Next intCnt
- End
|