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

"g_RsEngineer is not declared" error.

Hi,

 

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?

 

Thanks

11 REPLIES

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
		part1.DemandAll(True)
		
		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
		Next

    End Sub

Best Regards

 

Christian

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

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


    Public Sub RefreshStep(stack As Object)
       g_RsEngineer.RefreshModelViews(-1)
        'msgbox("The Refresh function was called")
    End Sub 

End Module

Error:

"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?

AutoSetRsEngineer=0

 

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?

Solution
Solution
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

 

Christian

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

Result = STATUS_ENABLED


See the picture Below.

 

 

Capture.PNG

 

Gene Libardi
Principal Solutions Architect
Engineering Intent Corporation
www.EngineeringIntent.com


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

 

AutoSetRsEngineer=1

 

You can find the Rulestream.ini file here:

C:\ProgramData\RuleStream\8.11.0

 

or you set it within the options.

Option.jpg

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.