LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Disable a Node Using Scripting

Solved!
Go to solution

So lets say I have a VI.  Using scripting I can find all objects of a particular type on the block diagram.  Now is there an easy way to say draw a Disabled Diagram structure around all nodes I found?

 

Like lets say I want to find all property nodes on a block, and disable them.  The only solution I found was to find all property nodes, using the Traverse for GObjects, then I can make a new Disabled Structure with the New VI object, place it at the same location, and bounds as the property node, with the same owner.  But then I still need to move the property node into the disabled case of the structure.  But then I have all kinds of broken wires that were once wired to the property node that I now moved.  I then need to figure out how it was wired before the move, wire it to the tunnel of the Disabled Structure, then wire from the tunnel to the terminal on the property node.  I need to do this for each terminal wired, and for each property node.  And then I need to wire through the enabled case of the structure.

 

What I was hoping to find is a way to draw the disabled diagram structure using scripting, but perform the same action as if I drew the structure, and have this also put any nodes I captured with my draw, into the disabled case.  Is there a way to do this with scripting?  Can someone think of an easier way to disable nodes using the Disabled Diagram structure?  Thanks.

0 Kudos
Message 1 of 8
(3,618 Views)
Solution
Accepted by topic author Hooovahh

Try using the Enclose Selection method. There's a shipping example for it here:

 

examples\Application Control\VI Scripting\Moving Objects\Enclose Selection And Move.vi

 

...aaaand I'm just now finding out after opening that example that somebody deprecated that method recently in favor of a new Enclose Selection 2 method. I'll get the example updated. 

 

Anyway, the weird thing about this method is that you have to give the method a reference to an actual structure to define what type of structure you want to wrap the code with. This usually requires dropping a dummy structure, calling Enclose Selection 2, then deleting the dummy structure after the code gets wrapped.

Message 2 of 8
(3,589 Views)
Solution
Accepted by topic author Hooovahh

This might help get you on the right track. I couldn't figure out how to delete the dummy structure afterwards though... I was going off a post by Yair in LAVA:

 

https://lavag.org/topic/19208-insert-conditional-disable-structure-around-call-library-nodes/

 

 Edit: And after working for 15 mins and posting I see Darren's well explained post above  Smiley Embarassed

Message 3 of 8
(3,584 Views)

 

@ gregoryj : your file "Enclose in Disable.zip" ... just a small problem (the "main problem")

 

the other problems are secondary

 

 

toto.png

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

What Greg posted for demonstration purposes was perfect.  Yeah there is a coercion dot but who cares it is just a more specific class, and yeah he forgot to close some references, and sure he wrapped his disabled structure in a disable structure, but based on my description he knows I wouldn't have been using this on all Nodes, but instead an array of Nodes that matched some search criteria.  Thanks everyone for your help, now I just need some time to implement these improvements.

 

Oh and while we're closing references you forgot to close the new Enclose Selection 2 output which is the new structure made.

0 Kudos
Message 5 of 8
(3,478 Views)

...and sure he wrapped his disabled structure in a disable structure

 

yes, after the Invoke Node "Delete", there remains a disable structure on the BD. My comment was just for this, nothing else.
If you put the "New VI Object" to the right place, this problem does not occur.


you forgot to close the new Enclose Selection2 output : indeed, you are right.

0 Kudos
Message 6 of 8
(3,458 Views)

Thank you Ouadji,

 

I thought it was not deleting the structure, I didn't realize it had been wrapped in another structure itself!

0 Kudos
Message 7 of 8
(3,446 Views)

yep ... ok, that's all   Smiley Happy 

There was no other purpose in my comment.

0 Kudos
Message 8 of 8
(3,439 Views)