LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
ouadji

Scripting - method Move (add "Moved Object Reference)

Status: New

 

         scripting  -  "Move" ... please, add an output for "Moved Object Reference"  

 

                (like the invoke node "Create from Data Type" has an output "New Objet Reference)

 

                  SR1.png

 

 

SR2.png

10 Comments
Darren
Proven Zealot

Unless I'm missing something, the "reference out" terminal of the Invoke Node is what you want:

ref.png

AristosQueue (NI)
NI Employee (retired)

Darren: That works as long as your Move doesn't create a copy. It doesn't work if you

a) wire True to the Duplicate? terminal or

b) wire in an owner that is on a different VI.

 

If you do either of those two operations, I am not sure how you're supposed to get the duplicated object. I'm surprised there isn't an output parameter that is the duplicated refnum.

ouadji
Trusted Enthusiast

AristosQueue:

b) wire in an owner that is on a different VI.

(it's my case)

 

I'm surprised there isn't an output parameter that is the duplicated refnum.

(... me too. it would be very useful, really !)

Darren
Proven Zealot

Ok, I understand now...I've only ever used the Move method to move (not copy) an object within the same VI. For your case, I see how adding that output would be useful, and I've kudoed your idea. For now, here's the best workaround I can think of. Assuming you've given your source object a unique label, and after you've done the move/copy, call this VI:

 

vi.lib\Utility\traverseref.llb\TRef Find Object By Label.vi

 

You already have a reference to the owner of the newly moved/copied object, and assuming it has a unique label, your code would look something like this:

 

traverse by label.png

 

 

ouadji
Trusted Enthusiast

small mistake, sorry

ouadji
Trusted Enthusiast

Thank you Darren (for kudos and this workaround)

 

yes, i know this workaround,

 

but a "additional output" with the "Moved Object Reference" would be really easy and convenient.

 

R&D should add this output, really.

 

once again, thank you Darren.  Smiley Happy

AristosQueue (NI)
NI Employee (retired)

Another developer offered another workaround that works on the block diagram. This helps if you don't have a unique label (i.e., if you're making multiple copies of the same object within the same owner):

  1. Use the Create New Object to create a sequence structure in the owner
  2. Move your object into the sequence structure
  3. Use the sequence structure's properties to get the only object inside the structure
  4. Use the Remove Structure method to remove the sequence while leaving the contained object behind.

Obviously would be better to not have to use these workarounds. I'll add my kudos.

DFGray
NI Employee (retired)

Yet another workaround...  After you do the move, get the selection list from the target BD or FP.  This will contain references to all the moved code.  You will need to show scripting functions to see the selection list property, but you have probably already done this.

ouadji
Trusted Enthusiast

@DFGray :

 

nice workaround.

 

I did some tests ... this workaround works fine with a "normal" vi.

The array contains a single reference ...the reference of the object which has been moved.

 

But with the Diagram of the XNodeGenCodeScratchPad (xnode - ReplaceSelf ability) ... it does not work. (array SelList[] is empty)

 

but once again, in the case of a "normal vi", no problem. 

That said, I will remember this workaround, I would have never thought of that!

 

AristosQueue, DFGray, thank you both very much.

ouadji
Trusted Enthusiast

oops, I made a mistake, sorry.

This workaround also works fine in the case of the XNodeGenCode Diagram.

 

awesome!  Smiley Happy

 

DFGray, just this ... smiley prosterné.gif