From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Python object refnum

Solved!
Go to solution

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?

0 Kudos
Message 1 of 10
(1,871 Views)

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?

fabric_0-1679632194638.png

 

0 Kudos
Message 2 of 10
(1,813 Views)

+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

0 Kudos
Message 3 of 10
(1,789 Views)

@fabric wrote:

Surely all LV users are learning Python now?!


No.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 4 of 10
(1,779 Views)
Solution
Accepted by topic author fabric

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

fabric_0-1679632194638.png

 


In search, search for python and you will see this: 

Screenshot 2023-03-24 at 10.38.58 AM.png

 On the right top is the Python Object Refnum. 

 

I was able to get the example code to run fine.

snipa.png

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. 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 5 of 10
(1,772 Views)

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'
______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 6 of 10
(1,760 Views)

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:

fabric_0-1679867177703.png

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 🙂

 

0 Kudos
Message 7 of 10
(1,696 Views)

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).

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 10
(1,689 Views)

@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:

fabric_0-1679867177703.png

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: 

Jay14159265_0-1679950919943.png

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. 

 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 9 of 10
(1,639 Views)

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.

Message 10 of 10
(1,570 Views)