0 Replies Latest reply on Mar 27, 2016 3:34 PM by clutch-cargo

    VBS How to select all items in a layer?

    clutch-cargo Level 1

      I wish to select all the items (PageItems?) in a layer and then set the StrokeWidth to whatever I prefer (10, 20, etc.).  When I open my .dxf file it will have two layers; 'Unknown_Area_Type' and 'Unknown_Line_Type'.  I am successful up to line 14 in the script below but after that all I could fine was a JavaScript that I was trying to convert to vbs but no luck.  Any help would be great. (please excuse for my horrible formatting  - still learning).


      On another note, why is there no selection for VBscript when selecting Syntex Highlighting for posting code here?


      Set App = CreateObject("Illustrator.Application")
      Set FSO = CreateObject("Scripting.FileSystemObject")
      doJavaScript = "var fileRef = File.openDialog ('Select the Road DXF file to open:', '*.DXF', false); if(fileRef) filePath = fileRef.fsName;" 
      FileRef = App.DoJavaScript(doJavaScript)
      If (FSO.FileExists(fileRef)) Then
          Set AutoCADOpenOptions = App.Preferences.AutoCADFileOptions
          autoCADOpenOptions.MergeLayers = false
          CurrentInteractionLevel = App.UserInteractionLevel
          App.UserInteractionLevel = -1 ' aiDontDisplayAlerts
          App.Open fileRef, 2 ' aiCMYK
          App.UserInteractionLevel = CurrentInteractionLevel
          App.ActiveDocument.Layers.GetByName( "Unknown_Area_Type" ).Delete() 
          Set docRef = app.activeDocument  
          Set layers = docRef.layers  
          Set myLayer = layers ("Unknown_Line_Type") ' this defines the layer that you want to get the selection from  
          docRef.selection = null ' ensure there is nothing in the document selected already. this way you only get the selection you want.  
          for(Set a=0;a<myLayer.pageItems.length;a++){ ' here we are looping through each pageItem of myLayer.  
               var currentItem = myLayer.pageItems[a];  
               currentItem.selected = true;  
               currentItem.selected.StrokeWidth = 20  'this is also what I wish to add
      End if