Showing results for 
Search instead for 
Do you mean 
Solved! Go to solution

"g_RsEngineer is not declared" error.



Trying to use a custom.vb which contains g_rsEngineer object.


There is an error:

"g_RsEngineer is not declared"


Ther is somethink new in RS8.11? how to solve?




Betreff: "g_RsEngineer is not declared" error.

Hi Yuri,


how das your Custom.VB looks like?


Here an example on how it looks for a customer (comes still from older trainings Smiley Wink ) and this works fine with RS 8.11.0

Public Sub g_rsEngineer_RsUserRelease(ByVal sender As Object, ByVal e As CancelEventArgs) Handles g_RsEngineer.RsUserRelease
    'NOTE: Set e.cancel to true to stop further processing of the release

        'Grab current model from RS Engineer
		Dim part1 As Part
		part1 = g_rsEngineer.SelectedPart
        Dim currModel As IRsCurrentModel = g_RsEngineer.CurrentModel
		For Each spec As Spec In part1.Specs
			Dim strSpecName As String = spec.SystemID.ToString()

        If (strSpecName = "TEAMCENTERItem") Then
			g_rsEngineer.ReleaseOutput(part1.ObjId, spec.Name, "Items")
			g_rsEngineer.ReleaseOutput(part1.ObjId, spec.Name, "Structure")
		ElseIf (strSpecName = "TEAMCENTERObject")
			g_rsEngineer.ReleaseOutput(part1.ObjId, spec.Name, "Objects")
			g_rsEngineer.ReleaseOutput(part1.ObjId, spec.Name, "RelateObjects")
		End If

    End Sub

Best Regards



Betreff: "g_RsEngineer is not declared" error.

Option Strict Off
Option Explicit On

Imports Microsoft.VisualBasic
Imports System
Imports System.IO
Imports System.Data
Imports System.Collections
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Math
Imports System.Text
Imports System.ComponentModel
Imports System.Runtime.Remoting.Lifetime
Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports System.Runtime.InteropServices
Imports RuleStream
Imports RuleStream.Kernel
Imports RuleStream.DataService
Imports System.Linq
Imports DocumentFormat.OpenXml
Imports DocumentFormat.OpenXml.Packaging
Imports DocumentFormat.OpenXml.Spreadsheet

Module Custom

    Sub hello()
        msgbox("Hello, Beautiful World!")
    End Sub
    Public Function hello_function () As String
        msgbox("Hello, Beautiful World!")
        Return Nothing
    End Function

    Public Sub RefreshStep(stack As Object)
        'msgbox("The Refresh function was called")
    End Sub 

End Module


"C:\ProgramData\RuleStream\8.11.1\temp\ETN_POC1\ETN_POC1\Custom.vb(43,0) : error BC30451: 'g_RsEngineer' is not declared. It may be inaccessible due to its protection level."

Betreff: "g_RsEngineer is not declared" error.

Can you take a look into your ini file if this is set?



If it is set to 1 ... it will fail without the necessary information’s in the custom.vb

Betreff: "g_RsEngineer is not declared" error.

[ Edited ]

hmm.. where could I find the .ini file?

Accepted by topic author EI_Yuri
‎07-04-2016 02:07 AM

Betreff: "g_RsEngineer is not declared" error.

Its one abve the masterdocuments. But I think I made a mistake.


can you please inser this into your module inside the custom.vb?

<ThreadStatic()> Public WithEvents g_RsEngineer As IRsEngineer

Best Regards



Re: "g_RsEngineer is not declared" error.

Once you havce declared the g_RSEngineer variable in your custom.vb, like this:


<ThreadStatic()> Public WithEvents g_RsEngineer As IRsEngineer


then put this code in the "Status" tab of the first step in the first process of your UI:


If g_RsEngineer Is Nothing Then
         g_RsEngineer = g_ObjectManager.RsEngineer
End If


See the picture Below.





Gene Libardi
Principal Solutions Architect
Engineering Intent Corporation

Re: "g_RsEngineer is not declared" error.

If you don't want to write always this small code block because you will use this in every application you can set as mentioned




You can find the Rulestream.ini file here:



or you set it within the options.


Re: "g_RsEngineer is not declared" error.

[ Edited ]
<ThreadStatic()> Public WithEvents g_RsEngineer As IRsEngineer

That helped, thanks you!

Could any of you expalin what does this code mean?


AutoSetRsEngineer = True - that doesn't work.




Re: "g_RsEngineer is not declared" error.

thanks, Gene,
yes I used this code.