# Extend SCPI Class in Python

**URL:** <https://forum.opentap.io/t/extend-scpi-class-in-python/1131>\
**Category:** Technical\
**Tags:** python, plugin\
**Created:** [May 30, 2023, 3:48pm UTC](https://forum.opentap.io/t/extend-scpi-class-in-python/1131 "2023-05-30T15:48:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrobin](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@jrobin](https://forum.opentap.io/u/jrobin)\
**Post date:** [May 30, 2023, 3:48pm UTC](https://forum.opentap.io/t/extend-scpi-class-in-python/1131/1 "2023-05-30T15:48:34Z")

</div>

I am currently attempting to extend the Scpi class to create a custom step that will return the query response as an output. Right now, I am just testing with returning a hard-coded value while maintaining the normal functionality of the original Scpi class. This is my code:

```csharp
@attribute(OpenTap.Display("SCPI Query", "Returns SCPI response", "Custom"))
class SCPIQuery(Scpi):
    # This is the output property that will be used by other steps
    ReturnValue = property(String,"Test")\
        .add_attribute(Display("Return Value", "", "Output", 0))\
        .add_attribute(Output())
    def __init__ (self):
      super(). __init__ ()
    def Run(self):
      super().Run()
      self.ReturnValue = self.ReturnValue + "10"

```

This is the log result:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opentap/original/1X/4e8174153482589cc78ed4b3880826fa5a81dae7.png)

How do I properly extend the Scpi class and use it in my Python plugin?

---

<div class="post-metadata">

**Author:** ![rolf\_madsen](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rolf\_madsen](https://forum.opentap.io/u/rolf_madsen)\
**Post date:** [May 31, 2023, 11:03am UTC](https://forum.opentap.io/t/extend-scpi-class-in-python/1131/2 "2023-05-31T11:03:29Z")

</div>

Hi @jrobin,

I am not completely sure what you are doing with `self.ReturnValue`

I think the class is called OpenTap.Plugins.BasicSteps.ScpiStep. So if you use that, I think your code should be valid.

---

<div class="post-metadata">

**Author:** ![jrobin](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@jrobin](https://forum.opentap.io/u/jrobin)\
**Post date:** [May 31, 2023, 5:29pm UTC](https://forum.opentap.io/t/extend-scpi-class-in-python/1131/3 "2023-05-31T17:29:30Z")

</div>

It seems as though ScpiStep is not recognized either? I got rid of the ReturnValue just for clarity. The same error from above appears when I try this code.

```csharp
@attribute(Display("Test", "Test", "A Test"))
class NewScpiStep(ScpiStep):
    def __init__ (self):
        super(). __init__ () 
        
    def Run(self):
        super().Run()

```

---

<div class="post-metadata">

**Author:** ![rolf\_madsen](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rolf\_madsen](https://forum.opentap.io/u/rolf_madsen)\
**Post date:** [May 31, 2023, 6:55pm UTC](https://forum.opentap.io/t/extend-scpi-class-in-python/1131/4 "2023-05-31T18:55:57Z")

</div>

Got it.

Well, for ScpiStep to be available to the scope when defining your class, so you need to import OpenTap.Plugins.BasicSteps (for example by `from ... import ScpiStep`.

And you might also need to add a reference to OpenTap.BasicSteps.dll by calling:`clr.AddReference("OpenTap.Plugins.BasicSteps")`
