Showing results 1 to 3 of 3

Thread: How to programmatically set the reaction matrix?

  1. #1
    Join Date
    17.03.2016
    Posts
    41

    Default How to programmatically set the reaction matrix?

    Hi,

    I'm trying to create a macro that will create new variables in the editor. 

    I can set properties such as net address & offset, but if I try to set the reaction matrix this way I get a runtime 438 "object doesnt support this property or method".

    The help file gives me the name of 'rema' for the reaction property to use in VBA, but I cant find any examples of what the syntax should be.

    Code:
    Set zenonVar = NewVariable("NewVar", zenonDriver, tpDriverVariable, "BOOL")
        zenonVar.Offset = 123
        zenonVar.NetAddr = 1
        zenonVar.Rema = "rema1"
    Can anyone give me an example of how to set this?

  2. #
    Join Date
    17.03.2016
    Posts
    41
    Best Answer

    Default Re: How to programmatically set the reaction matrix?

    I've written a function to do this now, so will post here in the spirit of Cunningham's law..

    Code:
    Public Function GetRemaIndex(RemaName As String) As Integer
    
    
      Dim i, j As Integer
        j = MyWorkspace.ActiveDocument.Remas.Count
        
        For i = 0 To j - 1
            'Debug.Print MyWorkspace.ActiveDocument.Remas.Item(i).DynProperties("ID")
           ' Debug.Print MyWorkspace.ActiveDocument.Remas.Item(i).DynProperties("Name")
            If MyWorkspace.ActiveDocument.Remas.Item(i).DynProperties("Name") = RemaName Then
                GetRemaIndex = MyWorkspace.ActiveDocument.Remas.Item(i).DynProperties("ID")
                Exit Function
            End If
            
        Next i
    
    
        'Wasn't found so set as nothing
        Debug.Print RemaName + " Not found"
        GetRemaIndex = 0
        
    End Function


    That way you can use
    Code:
    zenonVar.DynProperties("Rema") = GetRemaIndex("testrema1")
    to set the reaction matrix in a single line of code.... seems to work but I stand to be told a more efficient method
    Last edited by HMIdeveloper123 : 2nd August 2017 at 16:24 Reason: tried to fix code tags... they're broken

  3. #2
    Join Date
    17.03.2016
    Posts
    41

    Default Re: How to programmatically set the reaction matrix?

    so I have been able to set this based on the post here:

    https://forum.copadata.com/showthread.php?3417-Rema-Object-einem-Limit-zuordnen&highlight=dynproperties

    only using the 'ID' of the reaction matrix (which was easy to figure out as this was a test project with only 1 listed).

    Code:
    zenonVar.DynProperties("Rema") = "1"
    I feel like the VBA documentation is quite lacking here... the rema help only shows how to create one & the help for variable dynamic properties for rema has a link which takes you to the Reaction Matrix page (with no VBA guidance). No worked examples or any other info to state you must assign it to the ID of the reaction matrix.


  4. #3
    Join Date
    17.03.2016
    Posts
    41
    Best Answer

    Default Re: How to programmatically set the reaction matrix?

    I've written a function to do this now, so will post here in the spirit of Cunningham's law..

    Code:
    Public Function GetRemaIndex(RemaName As String) As Integer
    
    
      Dim i, j As Integer
        j = MyWorkspace.ActiveDocument.Remas.Count
        
        For i = 0 To j - 1
            'Debug.Print MyWorkspace.ActiveDocument.Remas.Item(i).DynProperties("ID")
           ' Debug.Print MyWorkspace.ActiveDocument.Remas.Item(i).DynProperties("Name")
            If MyWorkspace.ActiveDocument.Remas.Item(i).DynProperties("Name") = RemaName Then
                GetRemaIndex = MyWorkspace.ActiveDocument.Remas.Item(i).DynProperties("ID")
                Exit Function
            End If
            
        Next i
    
    
        'Wasn't found so set as nothing
        Debug.Print RemaName + " Not found"
        GetRemaIndex = 0
        
    End Function


    That way you can use
    Code:
    zenonVar.DynProperties("Rema") = GetRemaIndex("testrema1")
    to set the reaction matrix in a single line of code.... seems to work but I stand to be told a more efficient method
    Last edited by HMIdeveloper123 : 2nd August 2017 at 16:24 Reason: tried to fix code tags... they're broken

Similar Threads

  1. Delay in reaction matrix
    By andrey_k in forum zenon Energy Edition
    Replies: 3
    Last Post: 13th November 2018, 13:32
  2. reaction matrix
    By robolution in forum zenon Supervisor
    Replies: 2
    Last Post: 9th May 2013, 13:51
  3. Reaction Matrix
    By archie in forum zenon Energy Edition
    Replies: 6
    Last Post: 24th May 2012, 18:26
  4. Reaction matrix ?
    By peterg in forum zenon Supervisor
    Replies: 2
    Last Post: 5th August 2009, 01:05
  5. Reaction Matrix
    By stephanepilon in forum zenon Supervisor
    Replies: 3
    Last Post: 1st May 2008, 16:02

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •