Oh, forgot to add a the script will entail several programs that require vbscript. But I must say this little adventure is getting more familiar with javascript
Now if you happen to attack what you have in vbscript I would be the last to complain, ha!
So here is the script so far. It works great with the first Find Fill Color but at line
FindFill2 = App.ExecuteMenuCommand("Find Fill Color menu item")
the 2nd fill color changes color correctly but it never selects any matching paths. Can you see where I am goin wrong?
Set App = CreateObject("Illustrator.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = FSO.GetFolder("C:\SOCAL\Section_32\Land Cover")
Dim dFolder : dFolder = "C:\SOCAL\Section_32\Veg DXFs LC"
Dim FileRef, docRef, docRef2
For Each FileRef In SourceFolder.Files
Set myDoc = App.Open(FileRef.Path,2)
App.DoScript "LandCover-1", "Land Cover Auto"
App.DoJavaScriptFile "C:\Custom_Trace.js"
App.DoScript "LandCover-2", "Land Cover Auto"
'========================== fillcolor pine ========================
Set iFillColor = CreateObject("Illustrator.RGBColor")
iFillColor.Red = 28
iFillColor.Green = 99
iFillColor.Blue = 48
Set myDoc.DefaultFillColor = iFillColor
FindFill = App.ExecuteMenuCommand("Find Fill Color menu item")
Dim docSelected
docSelected = App.DoJavaScript("var doc = app.activeDocument;doc.selection.length;")
' ========================= saving file =============================
' note - here I check if any paths selected, if Yes I save file. If no, I just close file
If docSelected > 0 Then
App.DoScript "LandCover-3", "Land Cover Auto"
dFile = dFolder + "\SOCAL_CK67_pineLC.dxf"
Set docRef = App.ActiveDocument
Set dxfExport = CreateObject("Illustrator.ExportOptionsAutoCAD")
dxfExport.ExportFileFormat = 0 ' 0 = aiDXF
docRef.Export dFile, 8, DXFexport
docRef.Close 2 ' aiDoNotSaveChanges
Set docRef = Nothing
Else
Set docRef = App.ActiveDocument
docRef.Close 2
Set docRef = Nothing
End If
'========================== 2nd fillcolor scrub ========================
Set myDoc2 = App.Open(FileRef.Path,2)
App.DoScript "LandCover-1", "Land Cover Auto"
App.DoJavaScriptFile "C:\Custom_Trace.js"
App.DoScript "LandCover-2", "Land Cover Auto"
Set iFillColor2 = CreateObject("Illustrator.RGBColor")
iFillColor2.Red = 204
iFillColor2.Green = 186
iFillColor2.Blue = 124
Set myDoc2.DefaultFillColor = iFillColor2
FindFill2 = App.ExecuteMenuCommand("Find Fill Color menu item")
Dim docSelected2
docSelected2 = App.DoJavaScript("var doc = app.activeDocument;doc.selection.length;")
If docSelected2 > 0 Then
App.DoScript "LandCover-3", "Land Cover Auto"
dFile = dFolder + "\SOCAL_CK67_scrubLC.dxf"
Set docRef2 = App.ActiveDocument
Set dxfExport = CreateObject("Illustrator.ExportOptionsAutoCAD")
dxfExport.ExportFileFormat = 0 ' 0 = aiDXF
docRef2.Export dFile, 8, DXFexport
docRef2.Close 2 ' aiDoNotSaveChanges
Set docRef2 = Nothing
Else
Set docRef2 = App.ActiveDocument
docRef2.Close 2
Set docRef2 = Nothing
End If
Next
' Note - I would add more loops (5 total) to find five different fill colors.