From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, 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: 

How to get Block Diagram image programmatically?

Hello, I found few methods, but results are wrong - many connections get broken.

 

This picture below shows screen dump from LabVIEW window:

4c-lvps.png

And this next was acquired programmatically (using VI Invoke "Node BD.Get Image Scaling") - here the broken connections can be seen:

4c-prog.png

 

The problem is that LabVIEW handles the VI alone, aside from the project the VI belongs to - and does not recognize objects defined in the project.

 

I tried to open the project in the application (the Open VI Reference function has an "application reference" input and I tried passing there a reference which I used to open the project with Application Invoke Node Project.Open), but the result was the same.

 

Possibly there is some way to tell the LabVIEW "handle the VI in a project context", but I spent 2 days looking for a way to do it, without success. Has anyone an idea?

 

Thakns in advance, Jerzy Tarasiuk

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

Have you tried the Print Method ?

 

zou_0-1625682606585.png

 

 

George Zou
0 Kudos
Message 2 of 10
(2,973 Views)

I think the trick is that you are looking at FPGA code and each FPGA target in the project is its own application context. You were right in that you have to use the application reference input for the open VI reference function but it has to specifically be the application reference of the FPGA item. I did this for a very simple project and you can see I got the project reference and instead of going straight to getting the application reference I had to traverse the project to find the FPGA target (I cheated a bit by only having one item under my computer so I could just index the first item from the ownedItems[] array).

 

picture.png

Matt J | National Instruments | CLA
0 Kudos
Message 3 of 10
(2,963 Views)

Post your script; I'll take a look at it.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 4 of 10
(2,961 Views)

Right today i tried the following - result as previously:

vibd2i.jpg

I will also try something like the script posted here by Jacobson.

 

. 

0 Kudos
Message 5 of 10
(2,956 Views)

The Jacobson's script did not work, but it told me a proper direction to go.

Here is a working VI block diagram (and the VI is attached):

vibd2i.png

The key is: use Application Invoke Node Project.Open, then get Project Property Node Targets, and find between them a target for which the VI is one of OwnedItems[] obtained from the target Property Node; then use the target Property Node to get Application and finally use the Application to open the VI.

 

Seems now it is working correctly for few VI-s I tried and I hope for the same for other VI-s.

Thanks for help which pointed me to the solution.

Jerzy Tarasiuk

 

 
0 Kudos
Message 6 of 10
(2,899 Views)

Yet another version - this processes all VI-s of a project.

 

pvibd2img1.vi - Convert BDs of all VI-s of a project to PNGs
controls: ProjectPath, LogFilePath, VI full paths, Image Counter in

indicators: -, Log path out, -, Image Counter out
* ProjectPath - a full path of LVPROJ file
* LogFilePath - a path of LogFile, may be relative
* VI full paths - full paths or names only of VI-s are listed
* Image Counter in - initial value for an image counter (0)
* Log path out - an expanded path of LogFile
* Image Counter out - final value of the image counter

 

Images are created in Application Directory, using names
bd%u.png, where the %u is substituted by the image counter;
the counter is incremented before its values is used, so
if it was 0, images will be named bd1.png, bd2.png, etc.

0 Kudos
Message 7 of 10
(2,874 Views)

Try this:

  1. Copy the attached file to C:\ ... \ LabVIEW 20xx\project
  2. Start LabVIEW (or close and restart if it was already open)
  3. Open your project
  4. From the menu, select Tools → Get BD Images
  5. Click on a VI name, and it will display the BD.
  6. Click on the Save  button to save the image
"If you weren't supposed to push it, it wouldn't be a button."
Message 8 of 10
(2,815 Views)

I tried my script on a project containing a VI which uses as SubVI a VI not being in the project. And the SubVI was not processed, therefore I modified the script, adding an ability to process dependencies (it is optional, controlled by Dependencies button.

I tried to use Find SubVIs property, but it didn't return SubVI-s used by a VI or a Target.

 

The included VI (as well as previous) can be invoked as a SubVI (e.g. by a main VI

which reads a list of project paths and makes FP/BD images of all VI-s in them).

Maybe it will be helpful for someone wanting to quickly review several projects.

 

By using a VI Invoke Node Print.VItoRTF, an RTF output can be created. In such a case, images of many VI-s can be output to one file if using Append input of the Invoke Node.

0 Kudos
Message 9 of 10
(2,752 Views)

Additional information on the pvibd2img2.vi

 

Controls (inputs to the VI):
LogFilePath (Path/String)
ProjectPath (Path/String)
VI Full Paths (Boolean)       Show full paths of VI-s in log
Image Counter in (Integer)  Image names "bd%u.png", start from number+1
Dependencies (Boolean)    Get dependent VI which aren't in the project

 

Indicators (outputs from the VI):
Log path out (Path/String; full path)
Image Counter out              Copy it to "in" before the next run

 

Log contains lines:
 VI=<path>.vi
  Image=bd<count>.png

- they tell which PNG is for which VI.

 

Below the VI block diagram:

pvibd2img2.png

0 Kudos
Message 10 of 10
(2,189 Views)