Why doesn´t work GetScriptObject in this plug-in?

This plug-in works properly until the command Rhino.islayervisible(strLayer). Anyone know why could be this? I am developing this plug-in with VB in Visual Studio 2015.

You can see my program below:

Imports System
Imports System.Collections.Generic
Imports Rhino
Imports Rhino.Commands
Imports Rhino.DocObjects
Imports Rhino.Geometry
Imports Rhino.Input
Imports Rhino.Input.Custom

Namespace ACTIVAR_CAPAS

<System.Runtime.InteropServices.Guid("c1135058-446c-4002-bae0-3aa90b39e42b"),
Rhino.Commands.CommandStyle(Rhino.Commands.Style.ScriptRunner)>
Public Class INCOMACTIVARCAPASCommand
    Inherits Rhino.Commands.Command

    Shared _instance As INCOMACTIVARCAPASCommand


    '''<returns>The command name as it appears on the Rhino command line.</returns>
    Public Overrides ReadOnly Property EnglishName() As String
        Get
            Return "INCOMACTIVARCAPAS"
        End Get
    End Property

    Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result
        Dim Rhino, objRhinoScript As Object


        objRhinoScript = CreateObject("Rhino5x64.Interface")
        If (Err.Number <> 0) Then
            RhinoApp.WriteLine("Unable to create Rhino5x64.Interface object")
            Exit Function
        End If


        Rhino = objRhinoScript.GetScriptObject

        If (Rhino Is Nothing) Then
            RhinoApp.WriteLine("Failed to get Rhinoscript object")
            Exit Function
        Else
            RhinoApp.WriteLine("Rhino object created.")


        End If

        Dim arrLayers As Array
        Dim strLayer As String


        arrLayers = Rhino.LayerNames

        If IsArray(arrLayers) Then

            For Each strLayer In arrLayers

                If Rhino.islayervisible(strLayer) = False Then

                    Rhino.layervisible(strLayer, True)

                End If



            Next

        End If

        Rhino = Nothing

        objRhinoScript = Nothing

        Return Result.Success


    End Function
End Class

End Namespace

Hi @javiervg84,

When writing .NET plug-ins for Rhino, you will be using the RhinoCommon API, not RhinoScript.

– Dale

Hi dale,

I know that but I´d like to use rhinoscript because is easier for me. Do you know any tutorial to learn rhinocommon?

Thank you.

Hi @javiervg84,

You can begin to learn more about RhinoCommon here:

And, there are lots of code samples on our GitHub site:

– Dale