|
经典图书 我的宏,在转到VB6中后,读材料属性,返回为空,有时能返回属性内容,但评估值一直是空,有时,两个都是空串。
请看看程序有什么问题
- Set swApp=Application.SLDWORKS
- Set SubPartDoc = swApp.ActiveDoc
- ConfString = SubPartDoc.GetActiveConfiguration.Name
- Set config = SubPartDoc.GetActiveConfiguration
- Set CustPropMgr = config.CustomPropertyManager
- lRetVal = CustPropMgr.Get5("Material", False, ValOut, ResolvedValOut, wasResolved)
复制代码 在VB6中调试执行或输出为EXE来执行,ResolvedValOut都是空串,ValOut有时为空,有时有正确值,
我的模型确认是设定了Material属性的,也设定好材料的。
同一个代码,在SW的宏编辑器中是OK的。
还有另一个是在网上找的,不打开文件 ,在资源管理器中读取文件的详细信息。用来读取SW文件的Description
同样在SW的宏编辑器中是OK的,但在VB6中使用时,别的详细信息都能读到,但读Description也是空串。
代码如下 :
- Function getfilePTY(ByVal strFl As String, ByVal key As String) As String
- Dim fso 'As FileSystemObject
- Dim fl 'As Scripting.File
- Dim pth As String
- Dim flname As String
- Dim shl As Shell32.shell
- Dim shfd As Shell32.folder
- Dim s As String
- Dim i
- 'Set fso = New FileSystemObject
- Set fso = CreateObject("scripting.filesystemobject")
- Set fl = fso.GetFile(strFl)
- pth = fl.ParentFolder.path
- flname = fl.Name
- Set shl = New shell
- Set shfd = shl.NameSpace(pth)
- For i = 0 To 500
- If shfd.GetDetailsOf(0, i) = key And shfd.GetDetailsOf(shfd.Items.Item(flname), i) <> "" Then
- Debug.Print shfd.GetDetailsOf(0, i), shfd.GetDetailsOf(shfd.Items.Item(flname), i)
- s = s & shfd.GetDetailsOf(0, i) & ": " & shfd.GetDetailsOf(shfd.Items.Item(flname), i) & Chr(10)
- End If
- Next i
- getfilePTY = s
- End Function
复制代码
|
|