Export *obj script

Cheers all,

I am quite noob into scripts and i have discovered this export objetcs by layer script…
But when i modify it as the tutorial said and i dont really know what i am doing wrong. I copy the script modified i am trying to introduce…

Option Explicit

Sub ExportLayerObjectsIGES

’ Declare local variables
Dim strPath, strFile
Dim arrLayers, strLayer
Dim arrSelected

’ Get the path to and name of the current document.
’ Surround with double-quotes in case path includes spaces.
strPath = Chr(34) & Rhino.DocumentPath & Rhino.DocumentName & Chr(34)

’ Get names of all layers
arrLayers = Rhino.LayerNames

’ Disable redrawing
Rhino.EnableRedraw False

’ Process each layer
For Each strLayer In arrLayers

  ' Unselect all   
  Rhino.Command "_-SelNone", 0
  ' Select all objects on layer. Surround layer name
  ' with double-quotes in case it includes spaces.
  Rhino.Command "_-SelLayer " & Chr(34) & strLayer & Chr(34), 0
  ' Make sure some objects were selected
  arrSelected = Rhino.SelectedObjects
  If IsArray(arrSelected) Then
  	' Generate a modified path string
  	' that includes the layer name
  	strFile = strPath
  	strFile = Replace(strFile, ” .3dm“, ” _ & strLayer & . * obj“)
  	' Export the selected objects
  	Rhino.Command "_-Export " & strFile, 0
  End If

Next

’ Unselect all
Rhino.Command “_-SelNone”, 0

’ Enable redrawing
Rhino.EnableRedraw True

End Sub

I think you have “curly quotes” in there

strFile = Replace(strFile, ” .3dm“, ” _ & strLayer & . * obj“)

instead of straight quotes:

strFile = Replace(strFile, " .3dm", " _ & strLayer & . * obj")

That’s why the error message says “invalid character”.

You need to use a text editor that uses straight ASCII.

Does that help? --Mitch

1 Like

Yep, you were completly right Mitch. It was just the curly quotes.
Thank you very much for your help
Dani