|
'上层文件是否只读
Dim swConfigMgr As SldWorks.ConfigurationManager
Dim swConf As SldWorks.Configuration
Dim swParentComp As SldWorks.Component2
Dim bRet As Boolean
Set swapp = Application.SldWorks
Set swModel = swapp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swComp = swSelMgr.GetSelectedObjectsComponent4(1, -1)
Set swParentComp = swComp.GetParent
If Nothing Is swParentComp Then
Set swConfigMgr = swModel.ConfigurationManager
Set swConf = swConfigMgr.ActiveConfiguration
Set swParentComp = swConf.GetRootComponent3(True)
End If
'filePath = swComp.GetPathName
'filePath = swModel.GetPathName
FileAttrPath = swParentComp.GetPathName
'MsgBox FileAttrPath
DocPathSplit = Split(swParentComp.GetPathName, "\") '分割
txttype = DocPathSplit(UBound(DocPathSplit))
txttype = Left(txttype, Len(txttype) - 7) '排除后缀
txttype = "选中部件的上层文件" + " " + txttype + " "
FileAttribute '判断文件是否只读
If Label2 = txttype + "文件未检出,无法重命名,请检出!" Then
CommandButton2.Enabled = False
Exit Function
End If |
|