Batch Processing

Batch Processing

Anonymous
Not applicable
435 Views
1 Reply
Message 1 of 2

Batch Processing

Anonymous
Not applicable
Trying to write a really simple batch program. I have a bunch of
(1000's of) drawings in subdirectories that are unitless measure and I
want to change them to Architectural inches.

The script below is failing on the lines marked ">"
The Setvariable method is not available in the dropdown
Is this a missing reference?
Are my declarations all Wonky?
Are there any good examples for this type of processing anyone can share?

Thanks,

PS, in email there is a funky wordwrap issue on the "Set Mydir".. line -
it doesn't look like that in VBA.
--------------------------------------------------------


Sub BatchConvert()
Dim MyFile As File
Dim MyDir As Folder
Dim MySub As Folder
Dim MyFSO As New FileSystemObject

Set MyDir = MyFSO.GetFolder("C:\Documents and
Settings\rennenga\Desktop\test")
For Each MySub In MyDir.Files
For Each MyFile In MySub.Files
If MyFile.Type = "AutoCAD Drawing" Then

> MyFile.SetVariable "INSUNITS", 1
> MyFile.SetVariable "LUNITS", 4

End If
Next
Next

End Sub
0 Likes
436 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Ron,

Firstly I will start by saying I am no expert.

Just looking at your code, I noticed that you were trying to use the "Setvariable" with a filesystemobject. The Setvariable is an AutoCAD related method.

What references do you have??

See if this helps

Sub Archunits()

SearchDirs "C:\Documents and Settings\rennenga\Desktop\test", "*.dwg"

End Sub

Private Function SearchDirs(ByVal Directory As String, ByVal FileName As String) As Integer
Dim CurrentFile As String
Dim SubDirectory() As String
Dim SubDirCount As Integer
Dim FoundFileCount As Integer
Dim i As Integer

SubDirCount = 0
FoundFileCount = 0

' Get the files
CurrentFile = Dir(Directory & "\" & FileName) ' Retrieve the first entry.
Do While CurrentFile <> "" ' Start the loop.
Application.Documents.Open (Directory & "\" & CurrentFile)
ThisDrawing.SetVariable "INSUNITS", 1
ThisDrawing.SetVariable "LUNITS", 4

ThisDrawing.Save
ThisDrawing.Close

FoundFileCount = FoundFileCount + 1
CurrentFile = Dir() ' Get next entry.
Loop


' Get a list of the subdirectories.
CurrentFile = Dir(Directory & "\*.*", vbDirectory) ' Retrieve the first entry.
On Error GoTo NextFile
Do While CurrentFile <> "" ' Start the loop.
Select Case CurrentFile
Case "."
' Ignore this.
Case ".."
' Ignore this too.
Case Else
If (GetAttr(Directory & "\" & CurrentFile) And vbDirectory) > 0 Then
SubDirCount = SubDirCount + 1
ReDim Preserve SubDirectory(SubDirCount + 1)
SubDirectory(SubDirCount) = CurrentFile
Debug.Print CurrentFile
End If
NextFile:
End Select
CurrentFile = Dir() ' Get next entry.
Loop
On Error GoTo 0


' Go search each of them.
For i = 1 To SubDirCount
'DoEvents()
SearchDirs Directory & "\" & SubDirectory(i), FileName
Next i

SearchDirs = FoundFileCount
End Function
0 Likes