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: 

scripting: insert existing typedef into a cluster

Solved!
Go to solution

Using scripting, I can create typedefs and save them. I can create a control, open the typedefs and insert them into a cluster in the new control. But they are just clusters in the cluster and lose the connection to the typedef. I need to keep them as typedefs. I can do it manually by creating the cluster and dragging the typedefs in from a project, but can't get scripting to do it. Any brilliant scripters there?

0 Kudos
Message 1 of 8
(4,292 Views)

This works for me:

td in c.png

 

How were you doing it?

"If you weren't supposed to push it, it wouldn't be a button."
Message 2 of 8
(4,252 Views)

Great start, thanks. But now I want to add several more typedefs into the same cluster. Here, the NewViObject won't work, so I was using the Move method for the typedef cluster, with the owner being the main cluster. This works but inserts them as clusters, not typedefs.

I think I can make it work with the Move, then Replace method - still working the flow. Fortunately this is in a system setup procedure and not where performance is an issue.

0 Kudos
Message 3 of 8
(4,245 Views)

(Hate to reply to myself) but that worked. Akward, but works.

Using LV Scripting:

-Create Cluster

-Create Typedefs

-Cluster->Move typedef into cluster (set owner as cluster)

-Get refnum (Open VI Object Reference) to cluster formerly known as a typedef 

-Cluster->Replace with path to typedef

 

I now have a cluster full of typedefs.

If there's a better way, please let me know.

0 Kudos
Message 4 of 8
(4,242 Views)

... and I would suggest you mark your (previous) response as the "Solution", just in case someone else has the same (or related) issue.  Congratulations on your persistence and willingness to "experiment".

 

Bob Schor

0 Kudos
Message 5 of 8
(4,230 Views)
Solution
Accepted by topic author brimcd

I don't know why you think that "NewVi Object" won't work; it works just fine:

td 2 c.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 6 of 8
(4,225 Views)

I suspect that the reason you're not getting typedefs is that you are moving/copying a control from the FP of a typedef (which is not typdef'd) rather than moving/copying a control that is an instance of a typedef.

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

Pretty obvious why I didn't think it would work - cause I didn't think! Doh!

I Assumed it would create an additional cluster each time,  and didn't test it.

 

Thanks for correcting me

 

0 Kudos
Message 8 of 8
(4,206 Views)