Connect line using add_line command to same port connections
While I tried to collect lines in paralel, an error popup:
>> Battery_Array_tmp
Error using Battery_Array_tmp (line 33)
The first port already has a line connection
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
Can someone assist to solve it?
I adding part of rellevant script:
%%%% Scriptto creat top design – withot Batteries/
%%%% only to speedup simulation time during debug Block connections
open_system(‘Battery_arc_tmp’)
mdl = ‘Battery_arc_tmp’;
battery_model = find_system(mdl,’FindAll’,’on’,’Name’,’Battery_arc_tmp’);
numRows = 3;
% Get handle to existing (external) POS and NEG ports
Plus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
Minus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
%%% add MC_cube – basic String_unit:
for i=1:2 %% set two columns
colPos = 500; %% spaces between columns
for v=1:numRows %% loop for 5 String per column
nl=num2str(v + numRows*(i-1));
if i==1
% Add_MC_cube(v) = add_block(‘MC_Cube/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
else
% Add_MC_cube(v) = add_block(‘MC_Cube2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
end
posc = get(Add_MC_cube(v),’Position’);
set(Add_MC_cube(v),’Position’,posc + [100+(i-1)*colPos 100*(v-1)+45 100+(i-1)*colPos 100*(v-1)+45])
PH_Add_MC_cube{v,i}=get(Add_MC_cube(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
end
end
while connecting 2 module there is no problem/
But when increase above 2 module i gos an error message (above)..
please, see pic attached…
Thank for assist.
TommyWhile I tried to collect lines in paralel, an error popup:
>> Battery_Array_tmp
Error using Battery_Array_tmp (line 33)
The first port already has a line connection
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
Can someone assist to solve it?
I adding part of rellevant script:
%%%% Scriptto creat top design – withot Batteries/
%%%% only to speedup simulation time during debug Block connections
open_system(‘Battery_arc_tmp’)
mdl = ‘Battery_arc_tmp’;
battery_model = find_system(mdl,’FindAll’,’on’,’Name’,’Battery_arc_tmp’);
numRows = 3;
% Get handle to existing (external) POS and NEG ports
Plus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
Minus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
%%% add MC_cube – basic String_unit:
for i=1:2 %% set two columns
colPos = 500; %% spaces between columns
for v=1:numRows %% loop for 5 String per column
nl=num2str(v + numRows*(i-1));
if i==1
% Add_MC_cube(v) = add_block(‘MC_Cube/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
else
% Add_MC_cube(v) = add_block(‘MC_Cube2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
end
posc = get(Add_MC_cube(v),’Position’);
set(Add_MC_cube(v),’Position’,posc + [100+(i-1)*colPos 100*(v-1)+45 100+(i-1)*colPos 100*(v-1)+45])
PH_Add_MC_cube{v,i}=get(Add_MC_cube(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
end
end
while connecting 2 module there is no problem/
But when increase above 2 module i gos an error message (above)..
please, see pic attached…
Thank for assist.
Tommy While I tried to collect lines in paralel, an error popup:
>> Battery_Array_tmp
Error using Battery_Array_tmp (line 33)
The first port already has a line connection
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
Can someone assist to solve it?
I adding part of rellevant script:
%%%% Scriptto creat top design – withot Batteries/
%%%% only to speedup simulation time during debug Block connections
open_system(‘Battery_arc_tmp’)
mdl = ‘Battery_arc_tmp’;
battery_model = find_system(mdl,’FindAll’,’on’,’Name’,’Battery_arc_tmp’);
numRows = 3;
% Get handle to existing (external) POS and NEG ports
Plus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
Minus_MC = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
%%% add MC_cube – basic String_unit:
for i=1:2 %% set two columns
colPos = 500; %% spaces between columns
for v=1:numRows %% loop for 5 String per column
nl=num2str(v + numRows*(i-1));
if i==1
% Add_MC_cube(v) = add_block(‘MC_Cube/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
else
% Add_MC_cube(v) = add_block(‘MC_Cube2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
% % % % % % MC_TMP empty Submodule – only for quick compilation….
Add_MC_cube(v) = add_block(‘MC_TMP2/STRING_MC_Cube 1’, [mdl,’/STRING_MC_Cube ‘,nl]);
end
posc = get(Add_MC_cube(v),’Position’);
set(Add_MC_cube(v),’Position’,posc + [100+(i-1)*colPos 100*(v-1)+45 100+(i-1)*colPos 100*(v-1)+45])
PH_Add_MC_cube{v,i}=get(Add_MC_cube(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_MC_cube{v-1,i}.LConn(2),PH_Add_MC_cube{v,i}.LConn(2),’Autorouting’,’on’);
end
end
end
while connecting 2 module there is no problem/
But when increase above 2 module i gos an error message (above)..
please, see pic attached…
Thank for assist.
Tommy matlab, simulink MATLAB Answers — New Questions