5

I have some problems about signal name when I set a name to signal.

Now I can set and get signal name by

set_param(signal_h, 'SignalNameFromLabel', signal_name);

and

get_param(signal_h, 'Name');

But I can not set or get location of signal name.

I opened .mdl as text (notepad++) then I found *.mdl keep location of signal name as matrix in Labels parameter

So I would like to ask you all, How can I set or get location of signal name by command line.

Sorry for my English skill. Thank you for all answers.

enter image description here

  • Just to clarify: you want to set/get the graphical location of the label in the model? – pmb Nov 08 '13 at 07:40
  • interesting edit, though the .mdl files are about to be replaced by .slx (which are not that easy built anymore) - I don't know how long they keep .mdl. Anyway, the only solution I see so far, is to programatically modify the .mdl-file directly. It's defintely possible to detect your line and change the label position. But it's for sure a heavy script you need to write, if you want to consider branches also. With no branches I'd assume it is much easier, as the label property always follows the name property you use for detection. – thewaywewalk Nov 12 '13 at 11:54

2 Answers2

2

When you inspect your signal handle, you won't find any property changing, when you modify the signal position. So I would assume there is no simple way to do what you want. Maybe you can work with the underlying java objects, but it will complicated. (... and I can't help on that)

I assume you create your whole model programmatically, don't you? So you specify the exact position of your blocks and probably use the add_line command to draw the connections. Why not considering labeling the signals using annotations? You name your signal as before, but you don't make the label visible. Instead of this you use a programmatically generated annotation, like in the example of the documentation linked above:

new_system('test')
open_system('test')
add_block('built-in/Gain', 'test/Gain', 'Position', ...
[260, 125, 290, 155])
add_block('built-in/Note','test/programmatically created', ...
'Position', [550 0 0 180])

enter image description here

thewaywewalk
  • 24,484
  • 9
  • 62
  • 109
  • The only downside of doing this is if you then move the block and/or signal line, the annotation will not move with it. But I agree, I don't think there is a way to specify where the signal name appears on the signal line. – am304 Nov 08 '13 at 09:33
  • But if he "moves" the line by mouse, then I don't see the point of the question, because he could just move the label as well. But if everything is programmed, he could just "bundle" every generation of a signal with the generation of a new annotation, with dependent position. Interactivity is not the objective I guess. – thewaywewalk Nov 08 '13 at 09:54
  • True... I just thought it would be nice if when moving the line by mouse, the label would follow. – am304 Nov 08 '13 at 10:06
1

As thewaywewalk mentioned, there's no programmatic way of doing what you want (at least none that is documented). You can programmatically name a signal by setting the name parameter of the port or line that represents the signal:

p = get_param(gcb, 'PortHandles')
l = get_param(p.Outport, 'Line')
set_param(l, 'Name', 's9')

But according to the documentation, you can only move the signal label interactively with the mouse:

Move Signal Labels

Labels can appear above or below horizontal lines or line segments, and left or right of vertical lines or line segments. Labels can appear at either end, at the center, or in any combination of these locations.

To move a signal label, drag the label to a new location on the line. When you release the mouse button, the label fixes its position near the line. You cannot drag a label away from its signal, but only to a different location adjacent to the signal.

am304
  • 13,425
  • 2
  • 19
  • 36