Hi,
I still cannot understand the solution, i tried in many ways but it couldnt work. Can you please clarify much more
Thanks,
Tamer Mourad
Here it is
<CommandMethod("t13")>
PublicSubT13()
'Change the drawing Number
MsgBox("Please place all the sheet under the this path C:\x and create an empty folder under the C:\1 that drawings will be placed in")
Dim direc AsString = "C:\x"Dim filecount AsInteger = System.IO.Directory.GetFiles(direc, "*.dwg").Length
Dim arrfile() AsString = System.IO.Directory.GetFiles(direc, "*.dwg")
Dim val AsInteger = InputBox("Please Enter the value you want to add to the text")
Dim adedo AsEditor = Application.DocumentManager.MdiActiveDocument.Editor
Try
Dim i AsInteger= 0
For i = 0 To filecount - 1
Dim currentFile AsString= arrfile(i)
Dim doc AsDocument = Application.DocumentManager.Open(currentFile, False)
Dim db AsDatabase= doc.Database
Dim newfil AsString= Replace(currentFile, Mid(Right(currentFile, 7), 1, 3), Mid(Right(currentFile, 7), 1, 3) + val)
newfil = Replace(newfil,
"C:\x\", "C:\1\")
Dim doclock AsDocumentLock= doc.LockDocument
Usingdoclock
Dim trans AsTransaction= db.TransactionManager.StartTransaction()
Using(trans)
Dim ly1 AsLayoutManager = LayoutManager.Current
LayoutManager.Current.CurrentLayout = "Layout1"
trans.Commit()
EndUsingEndUsing
doc.Database.SaveAs(newfil,
True, DwgVersion.Current, doc.Database.SecurityParameters)
doc.CloseAndDiscard()
Next
Catch ex As Autodesk.AutoCAD.Runtime.Exception
MsgBox(ex.Message & vbLf & ex.StackTrace)
Finally
MsgBox("Done")
EndTry
EndSub
I assume you have this working from the posts here and in the other thread. Unless there is more to this, you don't need the database or a transaction. You also don't need an editor that I can see. This will do nothing if layout1 does not exist.
Using doclock
LayoutManager.Current.CurrentLayout = "Layout1"
End Using
If you do need the editor, declare it after you open the currentfile, like "dim adedo as editor = doc.editor".
Command flags session is described in the developers guide - a good page to bookmark. (http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html?url=WS1a919382...)
If you have to do more batch file processing do a google search for the openfiledialog class.
Hi,
I do need the editor and transaction for the rest of the program, however when i added this line next to the command method it worked
Autodesk.AutoCAD.Runtime.
CommandFlags.Session
Do you have any idea what does this line do?
By the way the hyperlink you attached is linking to something out of what i am asking for. R u sure from this bookmark
Thanks,
Tamer Mourad
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html
There is lots of help available on the internet. The main idea is to search first.
Can't find what you're looking for? Ask the community or share your knowledge.