Community
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Dave Preston" <The
href="mailto:dpreston@cadesignservices.co.uk">dpreston@cadesignservices.co.uk>
wrote in message
href="news:6061627@discussion.autodesk.com">news:6061627@discussion.autodesk.com...
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
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Tony Tanzillo" <
href="mailto:tony.tanzillo@THE_URL_BELOW.com">tony.tanzillo@THE_URL_BELOW.com>
wrote in message
href="news:6061678@discussion.autodesk.com">news:6061678@discussion.autodesk.com...
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.
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009
href="http://www.acadxtabs.com">http://www.acadxtabs.com
Introducing AcadXTabs 2010:
href="http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm">http://www.caddzone.com/acadxtabs/Acad...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Dave Preston" <The
href="mailto:dpreston@cadesignservices.co.uk">dpreston@cadesignservices.co.uk>
wrote in message
href="news:6061627@discussion.autodesk.com">news:6061627@discussion.autodesk.com...
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
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Dave Preston" <
href="mailto:dpreston@cadesignservices.co.uk">dpreston@cadesignservices.co.uk>
wrote in message
href="news:6061664@discussion.autodesk.com">news:6061664@discussion.autodesk.com...
Many thanks Tony, as ever. Is there a
programmatic equivalent of attsync or a workaround you can think
of?
--
Regards
Dave Preston
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Tony Tanzillo" <
href="mailto:tony.tanzillo@THE_URL_BELOW.com">tony.tanzillo@THE_URL_BELOW.com>
wrote in message
href="news:6061678@discussion.autodesk.com">news:6061678@discussion.autodesk.com...
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.
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD
2000 through 2009
href="http://www.acadxtabs.com">http://www.acadxtabs.com
Introducing AcadXTabs 2010:
href="http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm">http://www.caddzone.com/acadxtabs/Ac...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Dave Preston" <The
href="mailto:dpreston@cadesignservices.co.uk">dpreston@cadesignservices.co.uk>
wrote in message
href="news:6061627@discussion.autodesk.com">news:6061627@discussion.autodesk.com...
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
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Dave Preston" <
href="mailto:dpreston@cadesignservices.co.uk">dpreston@cadesignservices.co.uk>
wrote in message
href="news:6061664@discussion.autodesk.com">news:6061664@discussion.autodesk.com...
Many thanks Tony, as ever. Is there a
programmatic equivalent of attsync or a workaround you can think
of?
--
Regards
Dave Preston
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Tony Tanzillo" <
href="mailto:tony.tanzillo@THE_URL_BELOW.com">tony.tanzillo@THE_URL_BELOW.com>
wrote in message
href="news:6061678@discussion.autodesk.com">news:6061678@discussion.autodesk.com...
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.
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD
2000 through 2009
href="http://www.acadxtabs.com">http://www.acadxtabs.com
Introducing AcadXTabs 2010:
href="http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm">http://www.caddzone.com/acadxtabs/Ac...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Dave Preston" <The
href="mailto:dpreston@cadesignservices.co.uk">dpreston@cadesignservices.co.uk>
wrote in message
href="news:6061627@discussion.autodesk.com">news:6061627@discussion.autodesk.com...
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
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Tony Tanzillo" <
href="mailto:tony.tanzillo@THE_URL_BELOW.com">tony.tanzillo@THE_URL_BELOW.com>
wrote in message
href="news:6061686@discussion.autodesk.com">news:6061686@discussion.autodesk.com...
Aside from writing your own attsync, I think the
only
alternative is script pro.
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000
through 2009
href="http://www.acadxtabs.com">http://www.acadxtabs.com
Introducing AcadXTabs 2010:
href="http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm">http://www.caddzone.com/acadxtabs/Acad...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Dave Preston" <
href="mailto:dpreston@cadesignservices.co.uk">dpreston@cadesignservices.co.uk>
wrote in message
href="news:6061664@discussion.autodesk.com">news:6061664@discussion.autodesk.com...
Many thanks Tony, as ever. Is there a
programmatic equivalent of attsync or a workaround you can think
of?
--
Regards
Dave Preston
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Tony Tanzillo" <
href="mailto:tony.tanzillo@THE_URL_BELOW.com">tony.tanzillo@THE_URL_BELOW.com>
wrote in message
href="news:6061678@discussion.autodesk.com">news:6061678@discussion.autodesk.com...
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.
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD
2000 through 2009
href="http://www.acadxtabs.com">http://www.acadxtabs.com
Introducing AcadXTabs 2010:
href="http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm">http://www.caddzone.com/acadxtabs/...
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Dave Preston" <The
href="mailto:dpreston@cadesignservices.co.uk">dpreston@cadesignservices.co.uk>
wrote in message
href="news:6061627@discussion.autodesk.com">news:6061627@discussion.autodesk.com...
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