Batch DWG Error Coding

Batch DWG Error Coding

Anonymous
Not applicable
998 Views
20 Replies
Message 1 of 21

Batch DWG Error Coding

Anonymous
Not applicable
I have placed a .doc file in customer files that has the same topic name as this one The .doc file contains a snippet of code that I have been using for almost 2 years for batch processing idws out to dwgs. I recently had to resurrect it and update it to create dwgs for a customer. When I load the que with files it will process the first file without issue, but every subsequent file afterwards would hand up on the dwgAddIn.SaveCopyAs line in the code. When I placed a err.description line in there the immediate window said that it was a "Catastrophic Failure". Then I placed an On Error Resume Next line above it it continued to run but after saving the dwg a DBXbridge.exe error appeared on the screen telling me that there was a memory address error. Very strange...but the program continued to run and create all the dwgs. But for every dwg that it created there was an error message for it. Is there something in R7 that I need to add now? I don't know. Any advice is helpful. Mike
0 Likes
999 Views
20 Replies
Replies (20)
Message 2 of 21

Anonymous
Not applicable
Mike

I haven't used it in ages, but give the code on my site a try. I haven't heard of anyone
having any problems with it. You can find it at the bottom of this page
http://www.mymcad.com/KWiK/iCode/iBatchRun/ibatchrun.htm

--
Kent
Assistant Moderator
Autodesk Discussion Forum Moderator Program


"MDB" wrote in message news:f188ab3.-1@WebX.maYIadrTaRb...
> I have placed a .doc file in customer files that has the same topic name as this one The
.doc file contains a snippet of code that I have been using for almost 2 years for batch
processing idws out to dwgs.
0 Likes
Message 3 of 21

Anonymous
Not applicable
Kent, if you look at the code it mimics yours as well. I think we got it from the same place ;). Mike
0 Likes
Message 4 of 21

Anonymous
Not applicable
I thought it looked real close but I didn't compare it line for line. I thought there
might be some small difference. Will try to run it later today and see what happens
here.

--
Kent
Assistant Moderator
Autodesk Discussion Forum Moderator Program


"MDB" wrote in message news:f188ab3.1@WebX.maYIadrTaRb...
> Kent, if you look at the code it mimics yours as well. I think we got it from the same
place ;). Mike
0 Likes
Message 5 of 21

Anonymous
Not applicable
Ok, after spending 3 days working on this "DbxBridge.exe" error, I have concluded that it is most likely a bug with the API and VB. I have run Kents code do death in batchmode without error using the VBA macro. Charles sent me some coding as well, very similar to Kent's with the same results (no errors) in VBA. When I transpose the coding into VB I get the same memory error from the "DbxBridge.exe" everytime.

Maybe Brian would like to take a look at it.

The only fix I can think of is to shutdown the DbxBridge.exe before it errors and the export is complete. Mike
0 Likes
Message 6 of 21

arrakisman
Enthusiast
Enthusiast
**PING**

Any resolution on this. I am getting this error on Version 9 while exporting to DWG through VBA using a saveas.

Here is a sample of my Code.

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

If oDoc.DocumentType <> kDrawingDocumentObject Then
Exit Sub
End If
Dim addIns As ApplicationAddIns

Set addIns = oDoc.Parent.ApplicationAddIns

Dim dwgAddIn As TranslatorAddIn
Dim AddinCount As Integer
AddinCount = addIns.Count
Dim i As Integer
For i = 0 To AddinCount
If addIns.Item(i).Description = "Autodesk Internal DWG Translator" Then Set dwgAddIn = addIns.Item(i)
Next i

'Activate AddIns
dwgAddIn.Activate
Dim fname As String
Dim fnameMtr As String
fname = PPDfile
fnameMtr = Right(fname, 1)
If fnameMtr = "*" Then fname = Left(fname, 7) & "-" & ".dwg"
fname = PPDdir & fname

Dim iPath As Integer
Dim sPath As String
iPath = InStrRev(fname, "\")
sPath = Left(fname, iPath)
'Call createDWG(oDoc.Parent, dwgAddIn, fname, sPath)

Dim map As NameValueMap
Dim context As TranslationContext
Dim trans As TransientObjects
Set trans = oDoc.Parent.TransientObjects
Set map = trans.CreateNameValueMap
Set context = trans.CreateTranslationContext
context.Type = kFileBrowseIOMechanism
Dim b As Boolean
Dim file As DataMedium
Set file = trans.CreateDataMedium
b = dwgAddIn.HasSaveCopyAsOptions(file, context, map)

file.FileName = fname
'specify ini file from where the setting will be pickup

map.Value("Export_Acad_IniFile") = "L:\ENGR\Inventor Projects\Inventor Dev\EDT\BAC_dwg.ini"
dwgAddIn.SaveCopyAs oDoc, context, map, file

Any Ideas?
0 Likes
Message 7 of 21

Anonymous
Not applicable
I have not tried to do any exporting in R9. What is the error that you are receiving and can you post a jpg of it? Also do you know where it is occuring in your code?

Mike
0 Likes
Message 8 of 21

arrakisman
Enthusiast
Enthusiast
The error are the same as you described above at the same type only I am doing it through VBA. I don't have any way of compiling the code so I need to keep it through VBA. This attached is a screen shot after the "error saving file" pop up
0 Likes
Message 9 of 21

Anonymous
Not applicable
Man that demon looks familiar, but I got a fix. I'll have to post tomorrow.

I hope this does not continue to be a problem, because it disappeared in R8. Last time I only had the problem when using VB as my app. None the error is originating in the VBA.

Basically what I did was add a 2 second pause after the export completed then ran a sub that checked the running processes for the DBXBridge.exe. If it was running, the sub killed it.

I'll post it tomorrow.

Mike
0 Likes
Message 10 of 21

arrakisman
Enthusiast
Enthusiast
That would be great! Deffinatelly out of my league in debugging skills. Thanks for your help.

Ed
0 Likes
Message 11 of 21

Anonymous
Not applicable
Ed,

Here you go:

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

If oDoc.DocumentType <> kDrawingDocumentObject Then
Exit Sub
End If
Dim addIns As ApplicationAddIns

Set addIns = oDoc.Parent.ApplicationAddIns

Dim dwgAddIn As TranslatorAddIn
Dim AddinCount As Integer
AddinCount = addIns.Count
Dim i As Integer
For i = 0 To AddinCount
If addIns.Item(i).Description = "Autodesk Internal DWG Translator" Then Set dwgAddIn = addIns.Item(i)
Next i

'Activate AddIns
dwgAddIn.Activate
Dim fname As String
Dim fnameMtr As String
fname = PPDfile
fnameMtr = Right(fname, 1)
If fnameMtr = "*" Then fname = Left(fname, 7) & "-" & ".dwg"
fname = PPDdir & fname

Dim iPath As Integer
Dim sPath As String
iPath = InStrRev(fname, "\")
sPath = Left(fname, iPath)
'Call createDWG(oDoc.Parent, dwgAddIn, fname, sPath)

Dim map As NameValueMap
Dim context As TranslationContext
Dim trans As TransientObjects
Set trans = oDoc.Parent.TransientObjects
Set map = trans.CreateNameValueMap
Set context = trans.CreateTranslationContext
context.Type = kFileBrowseIOMechanism
Dim b As Boolean
Dim file As DataMedium
Set file = trans.CreateDataMedium
b = dwgAddIn.HasSaveCopyAsOptions(file, context, map)

file.FileName = fname
'specify ini file from where the setting will be pickup

map.Value("Export_Acad_IniFile") = "L:\ENGR\Inventor Projects\Inventor Dev\EDT\BAC_dwg.ini"
dwgAddIn.SaveCopyAs oDoc, context, map, file

'Continue processes and check the dreaded hanging
'DBX fiend
DoEvents
RefreshTask

Set file = Nothing
Set Context = Nothing
Set trans = Nothing

End Sub

'this jumps out to the module1.bas that is zipped in this thread.
'add the .bas to the rest of your modules, you may have to 'rename it.
Private Sub RefreshTask()

svar = EnumWindows(AddressOf getalltopwindows, 0)

End Sub

I know yesterday I mentioned adding a pause (or sleep) to wait and make sure the export has completed. But after sleeping on it it might be better to add a timer to your form and set the timer for 2-4 seconds. While the timer is running you can close your existing drawing and que up the next one for export.

I hope this all helps, I have not tried any of this in R9 yet.

Mike
0 Likes
Message 12 of 21

Anonymous
Not applicable
BTW, let us all know if it works.

Mike
0 Likes
Message 13 of 21

arrakisman
Enthusiast
Enthusiast
No Luck....I could just be using what you gave me wrong. The only change to my code I see was DoEvents and RefreshTask. I added that to the end of my code. Was it suppose to go to another place? I also imported the module1.bas file as a another module in my IVB.

I also recieve an error before the DBXbridge error. I attatched a picture.
0 Likes
Message 14 of 21

Anonymous
Not applicable
Ed,

Try the attached file. It is a standalone VB app I threw together to export your file. It is hardcoded to work with your ini file so it should work from the start.

Just make sure you have an IDW open when it runs.

There's not much error checking in it.

Let me know,
Mike
0 Likes
Message 15 of 21

arrakisman
Enthusiast
Enthusiast
Your's works fine.
0 Likes
Message 16 of 21

arrakisman
Enthusiast
Enthusiast
I even tried stripping out all the junk out of my code and hard coded the file destination and still no luck.
0 Likes
Message 17 of 21

arrakisman
Enthusiast
Enthusiast
Mike,

Thanks for your help. I don't want to take up any more of your time with this. Maybe this will convince the powers that be to get me a real version of VB.

Ed
0 Likes
Message 18 of 21

Anonymous
Not applicable
Can you email me your VBA app and I'll check it against my VB app?

Mike
mbest@REMOVEALLTHIS@tateornamental.com
0 Likes
Message 19 of 21

arrakisman
Enthusiast
Enthusiast
Mike,

They funny thing with this problem is it only does it with some files. What ever causes it, it would require me to send you idw's and model of the offending files. Due to the Company policy I can not do that (big surprise 🙂 ). I appreciate your help. More and more this is souinding like a bug in VBA.

Thanks alot.

Ed
0 Likes
Message 20 of 21

Anonymous
Not applicable
Quick questions:

1. Are you updating the drawings after you open them?
2. If you open the drawings, do nothing then close them are you prompted to save them?
3. Before you export the drawings are you waiting on the views to regenerate?
4. Do you have and acad sessions open when the drawings are exported?

I don't know, just grasping at straws here without seeing all the export code your using. Besides, your not taking up my time, this has become an obsession now.

Mike
0 Likes