If project is in single user mode and as such is not open by someone else then I don't understand how the sheet(s) can be locked. Are you saying that same user has multiple instances of Xpedition Designer running and each of these instances of Xpedition Designer has same project open? Update Other Objects should update all sheets (open or not by same user). In any case, I did try IsReadOnly() on sheet object and didn't get expected results for a sheet that is open. For an open sheet I was expecting IsReadOnly() to give me a true so I know that this sheet is locked. Another idea I have is that you can try modifying a sheet by drawing a non-electrical object such as line and if the return value of AddLine() is true then you can that sheet is NOT locked otherwise sheet is locked. Of course delete the line when return value is true.
yeah I was confused by the error as well for your stated reasons. So full picture here, my script is an automated method of creating the pageorder.txt file needed for hierarchy designs to get the page numbers correct for Cross Reference scout. In order to do this correctly I need to run update other objects to get the print order correct first. For whatever reason, despite properly disposing of my streamwriter, there's a lock on my pageorder.txt file after the script has run and scout will not run because of this. I've tried to figure this out but I'm not getting anywhere with it. The easy fix is to shut down the design and reopen it to get rid of the lock, however when I reopen the design and run the code again I get the sheets locked warning instead.
I either need a way to properly clear the lock on the pageorder.txt file or a way to unlock the sheets.
Here is the function I am using to create the pageorder.txt file. The function also adds the page number to a second location on the border. Maybe I am not disposing of everything properly.
Private Sub assignSheetNumbers(ByVal dictPaths As Dictionary(Of String, String))
Dim sSchematic As String
Dim schmObj As ViewDraw.IStringList
Dim compObj As ViewDraw.IVdObjs
Dim comp As ViewDraw.Component
Dim pushPathSheetNumber As String
Dim blk As ViewDraw.Block = Vdapp.ActiveView.TopBlock
Dim sTopBlock As String = blk.GetName(ViewDraw.VdNameType.SHORT_NAME)
Dim writer As StreamWriter = New StreamWriter(Vdapp.GetProjectData.GetProjectPath & "\pageorder.txt")
Vdapp.AppendOutput(appName, "Assigning sheetTop property...")
'steps through each sheet and pushes into hierarchy symbols
For Each sPath In dictPaths.Keys
sSchematic = dictPaths(sPath)
schmObj = Vdapp.SchematicSheetDocuments.GetAvailableSheets(sSchematic)
For y = 1 To schmObj.GetCount
pushPathSheetNumber = schmObj.GetItem(y)
Vdapp.PushPath(sTopBlock, sPath, pushPathSheetNumber)
compObj = Vdapp.ActiveView.Query(ViewDraw.VdObjectTypeMask.VDM_COMP, ViewDraw.VdAllOrSelected.VD_ALL)
For z = 1 To compObj.Count
comp = compObj.Item(z)
Dim attr1 As ViewDraw.Attribute
Dim attr2 As ViewDraw.Attribute
Dim sheetNum As String
attr1 = comp.FindAttribute("@printorder")
sheetNum = attr1.TextString.Replace("@PRINTORDER=", "")
attr2 = comp.FindAttribute("sheetTop")
attr2.InstanceValue = sheetNum
If sPath = "" Then
writer.WriteLine(sSchematic & "." & schmObj.GetItem(y).ToString & "," & sheetNum)
Vdapp.AppendOutput(appName, sSchematic & "." & schmObj.GetItem(y).ToString & "," & sheetNum)
writer.WriteLine(sPath & "\" & sSchematic & "." & schmObj.GetItem(y).ToString & "," & sheetNum)
Vdapp.AppendOutput(appName, sPath & "\" & sSchematic & "." & schmObj.GetItem(y).ToString & "," & sheetNum)
z = compObj.Count
writer = Nothing
comp = Nothing
compObj = Nothing
schmObj = Nothing
I don't know C# (is that what above code is?) so can't help much. My suggestion would be figure out why pageorder.txt file is locking. Try "defensive" programming such as looking for valid objects, etc. before proceeding to next line of code. Is there a reason you didn't implement this in VBScript because VBScript is what I see at support.mentor.com?
I usually use C# but this particular script is in vb.net. I can do more using Visual Studio than I can with VBScript and I find VBScript to be old and not worth expanding my personal capabilities in. If, for whatever reason, I needed a new job, I believe experience with VS will go further than VBScript.
Were you able to get your question answered? Let me know if you need any further guidance.