!This file is part of VEL_demo, copyright David Keyes, 2007. ! !This source file is free software: you can redistribute it and/or modify !it under the terms of the GNU General Public License as published by !the Free Software Foundation, either version 3 of the License, or !(at your option) any later version. ! !This code is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !For terms of the GNU General Public license see . ! replicates an existing part - except that the vectors ! ! become interactive - the vector message can be activated ! ! by uncommenting the list - 48 is the maximum number of ! ! parameters for the copied part (!) ! MACRO MODULE clone( REF clone_id > "@t16384 part to clone"); STRING name*10; INT type; INT attribute; REF csys_id; INT npar; INT nmem; REF mem_id(48); STRING p(48)*132, tmp*132; STRING pos*132; INT i, x, k; VECTOR orig_pos; CONSTANT INT typemask = 16384 ; BEGINMODULE FOR i:=1 TO 48 DO p(i):=""; ENDFOR; getprt(clone_id, name, type, attribute, csys_id, npar, nmem, mem_id); FOR i:=1 to npar DO x:=gettyp(clone_id, i); IF x = 1 THEN tmp:=str(getint(clone_id, i), 1,0); ELIF x = 2 THEN tmp:=str(getflt(clone_id, i), 1,4); ELIF x = 3 THEN tmp:=getstr(clone_id, i); !if any part of the string contains " then double it up ! k:=finds(tmp, chr(34)); if k <>0 then tmp:=substr(tmp,1,k-1) + chr(34) + substr(tmp,k); endif; tmp:=chr(34)+tmp+chr(34); ELIF x = 4 THEN orig_pos:=getvec(clone_id,i); !lst_ini("VECTOR MESSAGE"); !lst_lin("Cloning part has a vector parameter"); !lst_lin("The original location is "); !lst_lin("x : " + str(orig_pos.x,-1,12)); !lst_lin("y : " + str(orig_pos.y,-1,12)); !lst_lin("CHOOSE NEW LOCATION"); !lst_exi(); tmp:=pos_mbs("VECTOR PARAMETER x=" +str(orig_pos.x,-1,4) + ", y=" + str(orig_pos.y,-1,4)); ELIF x = 5 THEN tmp:=rstr(getref(clone_id, i)); ELSE exit("Can not find parameter type"); ENDIF; p(i):=tmp; ENDFOR; part(#1, addp_mbs("part",name, p, i)); ENDMODULE