Quantcast
Channel: Mentor Graphics Communities: Message List
Viewing all articles
Browse latest Browse all 4541

Re: appPED = CreateObject("MGCPCBLibraries.PartsEditorDlg") in VX not work?

$
0
0

Hi Guys,

 

THX for your help.

At first, all my other scripting is working with licensing Automation like listed at the end. Only my Library Script will do not.

I going through "Add Reference" and then parse to the dll. That works in 7.9.4 greatly, but not in VX (32bit).

I compile Scripts to exe.

So I will do have to read the manual now first....

 

All other VB-Express Scripts have add the COM. With this, I have no Problems. Ok. When I have to recompile,

I have to add correct COM, but existing Scripts compiled to exe works. Don't ask me, why.

 

 

This is, what I use for Open Object:

 

 

Option Strict Off

Option Explicit On '

 

Public Module mod_Automation_Module

 

    'DxDesigner Automation Globals

    'Public dxapp As ViewDraw.Application

    'Public dxdoc As Object

    'Public prj As ViewDraw.IProjectData

    'Public dxd_running As Boolean

    'Public dxd_project_open As Boolean

 

    'Expedition Automation Globals

    Public pcbapp As MGCPCB.Application

    Public pcbdoc As MGCPCB.Document

    Public pcb_running As Boolean

 

    '    Public Sub DX_Connect()

    '        Dim errmsg As String

    '        errmsg = ""

    '        dxd_running = False

    '        dxapp = Nothing

    '        On Error GoTo dxd_error

    '        errmsg = "Error: No active DxDesigner Application found."

    '        dxapp = GetObject(, "ViewDraw.Application")

    '        dxd_running = True

 

    '        prj = dxapp.GetProjectData

 

    'dxd_error:

    '        If Not errmsg = "" Then

    '            'msgbox(errmsg)

    '        End If

    '    End Sub

 

    '    Public Sub DX_Disconnect()

    '        dxapp = Nothing

    '    End Sub

 

    Public Sub MGCPCB_Connect()

        ' connects to MGCPCB

        Dim retVal As Short

        pcb_running = False

        On Error GoTo OnErrorGetObject

        pcbapp = GetObject(, "MGCPCB.Application")

        pcbdoc = pcbapp.ActiveDocument

        If Not pcbdoc Is Nothing Then

            pcb_running = True

        End If

        ' make sure the doc is licensed

        retVal = licenseDoc(pcbdoc)

        If (retVal <> 1) Then pcbdoc = Nothing

        Exit Sub

 

OnErrorGetObject:

        'MsgBox("MGCPCB needs to be running!")

    End Sub

 

 

    Public Sub MGCPCB_Disconnect()

        ' disconnects from MGCPCB.

        pcbdoc = Nothing

        pcbapp = Nothing ' Disconnect from MGCPCB server

    End Sub

 

    Public Function licenseDoc(ByRef docObj As MGCPCB.Document) As Short

        ' =======================================================================

        ' Retrieve a licence for the document

        ' =======================================================================

        On Error GoTo exit_with_error

        Dim retState As Short

        Dim licenseServer As Object

        Dim key As Integer

        Dim licenseToken As Integer

        Dim outErrMess As String

 

        If (docObj Is Nothing) Then GoTo end_of_function

        ' Ask the document for a key

        key = docObj.Validate(0)

        ' Get license server

        On Error GoTo err_create_serverobj

        licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")

        If (licenseServer Is Nothing) Then GoTo err_create_serverobj

        On Error GoTo exit_with_error

 

        ' Ask the license server for the license token

        licenseToken = licenseServer.GetToken(key)

 

        ' Validate the document with the license token

        On Error GoTo err_validate

        Dim lRetval As Integer

        lRetval = docObj.Validate(licenseToken)

 

        On Error GoTo exit_with_error

 

        retState = 1

 

end_of_function:

 

        ' release licence server

        licenseServer = Nothing

        licenseDoc = retState

 

        Exit Function

 

show_error:

        Dim ioptions As Integer

        ioptions = MsgBoxStyle.DefaultButton1 + MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly

        MsgBox(outErrMess, ioptions, "Retrieving license for document")

        GoTo end_of_function

 

exit_with_error:

        outErrMess = "** Error ** " & ErrorToString()

        retState = -1

        GoTo show_error

 

err_create_serverobj:

        outErrMess = "** Error ** Could not create license server object"

        retState = -2

        GoTo show_error

 

err_validate:

        outErrMess = "** Error ** Failed to validate document object"

        outErrMess = outErrMess & vbCrLf & "    License token : " & Trim(Str(licenseToken))

        outErrMess = outErrMess & vbCrLf & "    Document key  : " & Trim(Str(key))

        retState = -3

        GoTo show_error

 

    End Function

 

End Module


Viewing all articles
Browse latest Browse all 4541

Trending Articles