mlabell Posted September 3, 2008 Posted September 3, 2008 I am in the process of writing a routine to clean drawings that come from an outside source. What is happening is every once and awhile I will come across a drawing that is unstable and throws up the AutoCAD "Program Errors were detected. Recommend that you save your work and restart the program." Is there any way to prevent this in VBA from coming up, or is there a way to close it in VBA? Here is a snippet of the code that I have written. Sub dwgclean() Set objFSO = New FileSystemObject Set objFolder = objFSO.GetFolder(Me.txtFolderSource.Text) For Each objFile In objFolder.Files If objFile.Type = "AutoCAD Drawing" Then WholeFile = Me.txtFolderSource.Text & "\" & objFile.Name AutoCAD.AcadApplication.Documents.Open WholeFile ThisDrawing.PurgeAll ThisDrawing.PurgeAll ThisDrawing.PurgeAll ThisDrawing.PurgeAll ThisDrawing.SendCommand ("-purge r *" & vbCr & "n" & vbCr) ThisDrawing.AuditInfo True "THIS IS WHERE I NEED THE DIALOGUE CLOSE!" RemoveLayerFilters DeletePageSetups DeleteScaleList ThisDrawing.AuditInfo True ThisDrawing.SaveAs Me.txtFolderdestination.Text & "\" & objFile.Name ThisDrawing.Close End If Next deletebackup End Sub I have already tried the "nomutt", "expert", and "filedia" system variables with no help. If you need a drawing example let me know, and I will send it via email. Almost 10Mb... What would be ideal if I could somehow mimic the scriptpro ability to close dialogues. Quote
ML0940 Posted September 6, 2008 Posted September 6, 2008 mlabell Is the code in a VBA form? If so, you can use Userform.hide That will close the form and continue on ML Quote
mlabell Posted September 8, 2008 Author Posted September 8, 2008 Yes my code is in a form. But the error dialogue is an AutoCAD related dialogue when you audit a drawing several times to remove gunk. Whether the auditing done via script, lisp or vba the dialgoue is the standard warning to let the user know there is a drawing instability in the database. My ultimate goal would be to incorporate a scriptpro type control where it supresses any AutoCAD dialogue boxes... Quote
ML0940 Posted September 8, 2008 Posted September 8, 2008 SendKeys "{ESC}" That might work ASMI, good idea After the line ThisDrawing.AuditInfo True put SendKeys "{ESC}" I believe that you said that you have tried filedia, set to 0? Let me know if this still doesn't work, I can then try running the code. I see that you are using FSO, I like that! I use it all of the time! : ) ML Quote
ML0940 Posted September 8, 2008 Posted September 8, 2008 If you need a drawing example let me know, and I will send it via email. Almost 10Mb... If the aforementioned ideas don't work, then I can have you FTP the drawing to me, that won't be a problem ML Quote
alanjt Posted September 11, 2008 Posted September 11, 2008 would this apply to bypassing the popup from land desktop when a drawing is not associated with a project? i've been trying to bypass that forever. Quote
ML0940 Posted September 11, 2008 Posted September 11, 2008 Hi Alan This is one way to find out ML Quote
alanjt Posted September 11, 2008 Posted September 11, 2008 Hi Alan This is one way to find out ML sorry, i should have been a little more forthcoming. i don't know anything about vba; i only know lisp. i've been wanting to learn vba, but i just haven't really had the time, plus i read that it's going to be replaced with .net for autocad. i'd hate to go to the trouble of learning a language that is going to be obsolete in a year or 2 (in regards to autocad usage). Quote
ML0940 Posted September 11, 2008 Posted September 11, 2008 Hi Alan I am the opposite, I know a fairly good deal with VB and very little with LISP. As to whether or not VBA will go away altogether is yest to be seen, however, if you were to use VB.net down the road, I can tell you that knowing VBA will serve you a whole lot better then LISP. Having said that, there are like 4 other languages in .net, so you may not even decide on VB down the road ML Quote
alanjt Posted September 12, 2008 Posted September 12, 2008 Hi AlanI am the opposite, I know a fairly good deal with VB and very little with LISP. As to whether or not VBA will go away altogether is yest to be seen, however, if you were to use VB.net down the road, I can tell you that knowing VBA will serve you a whole lot better then LISP. Having said that, there are like 4 other languages in .net, so you may not even decide on VB down the road ML interesting to know. yeah, i've been wanting to start learning a new language, but i want to choose one that will benefit me in more ways than just autocad. i've also considered C since i found out that it will work within autocad. Quote
ML0940 Posted September 14, 2008 Posted September 14, 2008 Hey Alan Yes, you see, I have been doing VBA for about 5 years and VBscripting for almost 2 years, so it is almost a natural progression for me to dive into VB.net If I do that, then I feel like I would have a wide spectrum of The VB family covered, while building more value for myself In your case, since LISP is (for the most part) specific to ACAD, then it would be good for you to really think about which way you want to direct your energies. VB 2008 (.net) has two versions of C language, they are Visual C++ and Visual C#. I don't know much about either, though I have heard good things about C# Also, as Intermediate programming languages, in .net, you can program in C#, I can program in VB and we can still combine our code. So, that is pretty interesting. You can download Visual Studio 2008 Express Edition for free at http://www.microsoft.com/express/vb/default.aspx ML Quote
CmdrDuh Posted September 16, 2008 Posted September 16, 2008 Alanjt, there are lots of choices as far as which language to pick. VB.Net or C# are the 2 "easy" ones from Microsoft. C++ being the biggest undertaking, IMO, and the hardest to learn from what I have heard. But you can program Acad from other languages as well, like Python. There are threads showing all different ways to program Acad. All that being said, I would pick one that has lots of examples to learn by. C#, C++, and VB.net have the most examples that I have seen. If I was going to pick, I would pick in that order. C# seems to be the way Autodesk is going, judging by the examples they are posting on the internet, and the topics being covered in webcasts. Hope it helps Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.