|
Replies:
5
-
Last Post:
Oct 29, 2008 3:07 PM
Last Post By: Dave Preston
|
|
|
|
|
|
|
CloseAndSave problem
Posted:
Oct 29, 2008 2:23 PM
|
|
|
|
The following replaces all blocks with a file form disk then synchronises attributes:-
Public Sub RefreshBlocks()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Using docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
If
'code to replace blocks here
End If
trans.Commit()
Catch ex As System.Exception
MsgBox(ex.Message)
Finally
trans.Dispose()
End Try
doc.SendStringToExecute("_attsync n *" & ControlChars.Cr, True, False, False)
ed.Regen()
End Using
End Sub
This works perfectly well, but if I call it from a routine that opens a file it all works except the attsync. The blocks actually get swapped and if I exit the loop before the doc.closeandsave line the attributes actually update. It's probably something basic but it's baffled me:-
Sub ProcessAllDWGS()
Try
Dim dir As New DirectoryInfo("L:\work\ASDA\StoreSpace\Drawings\Final QA")
Dim files() As FileInfo
files = dir.GetFiles("*.dwg")
For Each file As FileInfo In files
Dim doc As Document = Application.DocumentManager.Open(file.FullName, False)
RefreshBlocks()
doc.CloseAndSave(file.FullName)
doc.Dispose()
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
-- Regards
Dave Preston
|
|
|
|
|
|
|
|
Re: CloseAndSave problem
Posted:
Oct 29, 2008 2:42 PM
in response to: Dave Preston
|
|
|
Reading this newsgroup and searching (if you can, that is) on the phrase 'SendStringToExecute' might help. SendStringToExecute() is just like VBA's SendCommand(), it's asynchronous, meaning that it returns before the commands that you pass it have finished. For that reason, I seriously doubt that what you're attempting to do is going to work. The following replaces all blocks with a file form disk then synchronises
attributes:-
Public Sub RefreshBlocks()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Using docLock As DocumentLock =
Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
If
'code to replace blocks here
End If
trans.Commit()
Catch ex As System.Exception
MsgBox(ex.Message)
Finally
trans.Dispose()
End Try
doc.SendStringToExecute("_attsync n *" & ControlChars.Cr, True, False,
False)
ed.Regen()
End Using
End Sub
This works perfectly well, but if I call it from a routine that opens a file it all works except the attsync. The blocks actually get swapped and if I exit the loop before the doc.closeandsave line the attributes actually update. It's probably something basic but it's baffled me:-
Sub ProcessAllDWGS()
Try
Dim dir As New DirectoryInfo("L:\work\ASDA\StoreSpace\Drawings\Final
QA")
Dim files() As FileInfo
files = dir.GetFiles("*.dwg")
For Each file As FileInfo In files
Dim doc As Document = Application.DocumentManager.Open(file.FullName, False)
RefreshBlocks()
doc.CloseAndSave(file.FullName)
doc.Dispose()
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
-- Regards
Dave Preston
|
|
|
|
|
|
|
|
|
Re: CloseAndSave problem
Posted:
Oct 29, 2008 2:50 PM
in response to: Tony Tanzillo
|
|
|
Many thanks Tony, as ever. Is there a programmatic equivalent of attsync or a workaround you can think of? -- Regards
Dave Preston
Reading this newsgroup and searching (if you can, that is) on the phrase 'SendStringToExecute' might help. SendStringToExecute() is just like VBA's SendCommand(), it's asynchronous, meaning that it returns before the commands that you pass it have finished. For that reason, I seriously doubt that what you're attempting to do is going to work. The following replaces all blocks with a file form disk then synchronises
attributes:-
Public Sub RefreshBlocks()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Using docLock As DocumentLock =
Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
If
'code to replace blocks here
End If
trans.Commit()
Catch ex As System.Exception
MsgBox(ex.Message)
Finally
trans.Dispose()
End Try
doc.SendStringToExecute("_attsync n *" & ControlChars.Cr, True, False, False)
ed.Regen()
End Using
End Sub
This works perfectly well, but if I call it from a routine that opens a file it all works except the attsync. The blocks actually get swapped and if I exit the loop before the doc.closeandsave line the attributes actually update. It's probably something basic but it's baffled me:-
Sub ProcessAllDWGS()
Try
Dim dir As New DirectoryInfo("L:\work\ASDA\StoreSpace\Drawings\Final
QA")
Dim files() As FileInfo
files = dir.GetFiles("*.dwg")
For Each file As FileInfo In files
Dim doc As Document = Application.DocumentManager.Open(file.FullName, False)
RefreshBlocks()
doc.CloseAndSave(file.FullName)
doc.Dispose()
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
-- Regards
Dave Preston
|
|
|
|
|
|
|
|
|
Re: CloseAndSave problem
Posted:
Oct 29, 2008 2:57 PM
in response to: Dave Preston
|
|
|
I suppose I could run ScriptPro on all files and just do the attsync in a script file --
Regards
Dave Preston
Many thanks Tony, as ever. Is there a programmatic equivalent of attsync or a workaround you can think of? -- Regards
Dave Preston
Reading this newsgroup and searching (if you can, that is) on the phrase 'SendStringToExecute' might help. SendStringToExecute() is just like VBA's SendCommand(), it's asynchronous, meaning that it returns before the commands that you pass it have finished. For that reason, I seriously doubt that what you're attempting to do is going to work. The following replaces all blocks with a file form disk then synchronises
attributes:-
Public Sub RefreshBlocks()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Using docLock As DocumentLock =
Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
If
'code to replace blocks here
End If
trans.Commit()
Catch ex As System.Exception
MsgBox(ex.Message)
Finally
trans.Dispose()
End Try
doc.SendStringToExecute("_attsync n *" & ControlChars.Cr, True, False, False)
ed.Regen()
End Using
End Sub
This works perfectly well, but if I call it from a routine that opens a file it all works except the attsync. The blocks actually get swapped and if I exit the loop before the doc.closeandsave line the attributes actually update. It's probably something basic but it's baffled me:-
Sub ProcessAllDWGS()
Try
Dim dir As New DirectoryInfo("L:\work\ASDA\StoreSpace\Drawings\Final
QA")
Dim files() As FileInfo
files = dir.GetFiles("*.dwg")
For Each file As FileInfo In files
Dim doc As Document = Application.DocumentManager.Open(file.FullName, False)
RefreshBlocks()
doc.CloseAndSave(file.FullName)
doc.Dispose()
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
-- Regards
Dave Preston
|
|
|
|
|
|
|
|
|
Re: CloseAndSave problem
Posted:
Oct 29, 2008 3:03 PM
in response to: Dave Preston
|
|
|
Aside from writing your own attsync, I think the only alternative is script pro.
Many thanks Tony, as ever. Is there a programmatic equivalent of attsync or a workaround you can think of? -- Regards
Dave Preston
Reading this newsgroup and searching (if you can, that is) on the phrase 'SendStringToExecute' might help. SendStringToExecute() is just like VBA's SendCommand(), it's asynchronous, meaning that it returns before the commands that you pass it have finished. For that reason, I seriously doubt that what you're attempting to do is going to work. The following replaces all blocks with a file form disk then synchronises
attributes:-
Public Sub RefreshBlocks()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Using docLock As DocumentLock =
Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
If
'code to replace blocks here
End If
trans.Commit()
Catch ex As System.Exception
MsgBox(ex.Message)
Finally
trans.Dispose()
End Try
doc.SendStringToExecute("_attsync n *" & ControlChars.Cr, True, False, False)
ed.Regen()
End Using
End Sub
This works perfectly well, but if I call it from a routine that opens a file it all works except the attsync. The blocks actually get swapped and if I exit the loop before the doc.closeandsave line the attributes actually update. It's probably something basic but it's baffled me:-
Sub ProcessAllDWGS()
Try
Dim dir As New DirectoryInfo("L:\work\ASDA\StoreSpace\Drawings\Final
QA")
Dim files() As FileInfo
files = dir.GetFiles("*.dwg")
For Each file As FileInfo In files
Dim doc As Document = Application.DocumentManager.Open(file.FullName, False)
RefreshBlocks()
doc.CloseAndSave(file.FullName)
doc.Dispose()
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
-- Regards
Dave Preston
|
|
|
|
|
|
|
|
|
Re: CloseAndSave problem
Posted:
Oct 29, 2008 3:07 PM
in response to: Tony Tanzillo
|
|
|
I've already run the first phase that swaps the blocks on 500+ files The problem with ScriptPro is that it is slow. Never mind, thanks for your help Tony -- Regards
Dave Preston
Aside from writing your own attsync, I think the only alternative is script pro.
Many thanks Tony, as ever. Is there a programmatic equivalent of attsync or a workaround you can think of? -- Regards
Dave Preston
Reading this newsgroup and searching (if you can, that is) on the phrase 'SendStringToExecute' might help. SendStringToExecute() is just like VBA's SendCommand(), it's asynchronous, meaning that it returns before the commands that you pass it have finished. For that reason, I seriously doubt that what you're attempting to do is going to work. The following replaces all blocks with a file form disk then synchronises
attributes:-
Public Sub RefreshBlocks()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Using docLock As DocumentLock =
Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
If
'code to replace blocks here
End If
trans.Commit()
Catch ex As System.Exception
MsgBox(ex.Message)
Finally
trans.Dispose()
End Try
doc.SendStringToExecute("_attsync n *" & ControlChars.Cr, True, False, False)
ed.Regen()
End Using
End Sub
This works perfectly well, but if I call it from a routine that opens a file it all works except the attsync. The blocks actually get swapped and if I exit the loop before the doc.closeandsave line the attributes actually update. It's probably something basic but it's baffled me:-
Sub ProcessAllDWGS()
Try
Dim dir As New DirectoryInfo("L:\work\ASDA\StoreSpace\Drawings\Final
QA")
Dim files() As FileInfo
files = dir.GetFiles("*.dwg")
For Each file As FileInfo In files
Dim doc As Document =
Application.DocumentManager.Open(file.FullName, False)
RefreshBlocks()
doc.CloseAndSave(file.FullName)
doc.Dispose()
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
-- Regards
Dave Preston
|
|
|
|
|
|