03-22-2023 10:33 PM
Seen here:
As of LV2022 we can now wire a Python Object Refnum into the Python Node. This allows a python object to be used as a return type or input parameter.
I tried this in LV2023 but didn't get far... Where do I get the python object refnum?
Solved! Go to Solution.
03-23-2023 11:31 PM
Anyone?
Surely all LV users are learning Python now?! The example posted by @DPrida shows this use case working, so it must be possible right?
03-24-2023 10:51 AM
+1
There's little to no documentation on the new functionality that I can find. If anyone can point in the right that would be greatly appreciated
03-24-2023 11:27 AM
@fabric wrote:
Surely all LV users are learning Python now?!
No.
03-24-2023 11:44 AM
@fabric wrote:
Anyone?
Surely all LV users are learning Python now?! The example posted by @DPrida shows this use case working, so it must be possible right?
In search, search for python and you will see this:
On the right top is the Python Object Refnum.
I was able to get the example code to run fine.
The only bad thing is you need wrapper methods for all your class methods. I have been using python with labview for years using IPC. This new python integration is nice to have but still a little rough around the edges.
03-24-2023 11:52 AM
Oops, I forgot to put the python code so here it is:
def create_class():
return LabViewTestClass()
def call_add_foo(obj, input: str):
return obj.add_foo(input)
class LabViewTestClass:
def __init__(self):
self.name = 'LabViewTestClass'
def add_foo(self, input: str):
return input + 'foo'
03-26-2023 04:49 PM
Thanks Jay, your solution is exactly what I was expecting!
It turms out that my LV2023 install seems to have some issues. My Python palette looks like this:
It is missing the object refnum!
I tried installing LV2023 on another machine and the palette looks correct: with six icons, including the object refnum (as per your screenshot).
The good news is that I can successfully use the refnum from the code snippet you uploaded, so I guess it is just a palette issue with my LV.
Thanks again 🙂
03-26-2023 05:32 PM - edited 03-26-2023 05:32 PM
Did you enable all palettes? LabVIEW often comes installed initially with a reduced palette to try to not overwhelm newcomers. If you go into the palette, pin it and then select the wrench tool, you can configure how the palette should be displayed (View This Palette As...) and what palettes should be visible (Change Visible Palettes).
03-27-2023 04:03 PM
@fabric wrote:
Thanks Jay, your solution is exactly what I was expecting!
It turms out that my LV2023 install seems to have some issues. My Python palette looks like this:
It is missing the object refnum!
I tried installing LV2023 on another machine and the palette looks correct: with six icons, including the object refnum (as per your screenshot).
The good news is that I can successfully use the refnum from the code snippet you uploaded, so I guess it is just a palette issue with my LV.
Thanks again 🙂
Hmm that is interesting, I have LabVIEW 2021 on another computer and when I search python I get:
I am wondering if you upgraded your LabVIEW 2023 install from an older version, and for some reason it did not update the functions palate.
03-29-2023 10:32 PM
Problem solved! It was just a palette issue...
I recently started a new job where "C:\Program Files\National Instrumnts\LabVIEW 20xx" is under SCC. Only a subset of files are actually checked in (e.g. "user.lib", "instr.lib", plus some other bits and pieces).
Unfortunately someone had also checked in the entire "menus" folder which includes all palette files. Therefore my LV2023 install was running with LV2020 palettes... Silly, but easy fix by just reverting that folder.