HI guys,
I'm sorry if this is a silly question but it has been driving me mad. I'm sure that I have made a basic mistake, but for the life of me, I cant see what it is. What I am trying to do is create a vba script which runs through a number of subfolders, opens the dgn files in them and displays all levels in a specific reference attachment ("3D-modell") in a specific model ("Drawings").
Dim myFSO As FileSystemObject
Dim myFSORoot As Folder
Dim FSOFolder As Folder
Dim FSOFile As File
Dim oMSAPP As MicroStationDGN.Application
Dim myDGN As DesignFile
Dim newDef As SheetDefinition
Dim oLevel As Level
Dim oAttachment As Attachment
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set oMSAPP = New MicroStationDGN.Application
Set myFSORoot = myFSO.GetFolder(ActiveWorkspace.ConfigurationVariableValue("MS_DESIGNDIR", True))
For Each FSOFolder In myFSORoot.SubFolders
For Each FSOFile In FSOFolder.Files
If Right(FSOFile.Name, 4) = ".dgn" Then
Set myDGN = oMSAPP.OpenDesignFileForProgram(FSOFile.Path, False)
For Each oAttachment In myDGN.Models("Drawing").Attachments
If oAttachment.AttachModelName = "3D-modell" Then
Debug.Print oAttachment.Levels.Count
For Each oLevel In oAttachment.Levels
oLevel.IsDisplayed = True
Next oLevel
End If
Next oAttachment
myDGN.Save
myDGN.Close
End If
Next FSOFile
Next FSOFolder
I know that I am locating the files okay. I know that I am finding the model I want to operate on okay and that it is even finding the reference but the debug.print line gives me a count of zero levels, thus oLevel is returned as "Nothing" and oLevel.IsDisplayed = True never runs.
Can anyone provide any tips where I am going wrong?
/James