// Copyright (C) 2001 Leena L�hteenm�ki, Finland // Copyright (C) 2012 PatternMaker Software // 2011/11/04 selection current_selection; object current_object, group_obj[100]; point current_point; double index, done, sv; double index, done; object marker_array[20]; double marker_count, loop; double vy, ly, sip, jsp, ik, ls, lx, polvi, lp; double size; double t_vy[8]; double t_ly[8]; double t_sip[8]; double t_jsp[8]; double t_ik[8]; double t_ls[8]; double t_lp[8]; double language; double sizes; double metric, sv; double read; double x[300],y[300]; main() { language=get_language(); if ( language != 0 ) { language = 0; } if (language == 0) { check_reg(0, "Leena","Children", "This macro needs to be properly installed before running it."); } Forward(); //Start Options while (!done) { if (index==0) { Popup1(); } if (index==1) { Popup2(); } if (index == 2) { Popup3(); } } //End Options t_vy[0]=55; t_vy[1]=56; t_vy[2]=57; t_vy[3]=58; t_vy[4]=59; t_vy[5]=60; t_vy[6]=62; t_vy[7]=64; t_ly[0]=62; t_ly[1]=64; t_ly[2]=66; t_ly[3]=68; t_ly[4]=70; t_ly[5]=73; t_ly[6]=76; t_ly[7]=79; t_sip[0]=62; t_sip[1]=66; t_sip[2]=70; t_sip[3]=74; t_sip[4]=78; t_sip[5]=82; t_sip[6]=86; t_sip[7]=90; t_jsp[0]=44; t_jsp[1]=47.5; t_jsp[2]=51; t_jsp[3]=54.5; t_jsp[4]=58; t_jsp[5]=61.5; t_jsp[6]=65; t_jsp[7]=68.5; t_lp[0]=35; t_lp[1]=35.5; t_lp[2]=36; t_lp[3]=36.5; t_lp[4]=37; t_lp[5]=37.5; t_lp[6]=38; t_lp[7]=39; t_ls[0]=29; t_ls[1]=29.5; t_ls[2]=30; t_ls[3]=30.5; t_ls[4]=31; t_ls[5]=31.5; t_ls[6]=32; t_ls[7]=33; vy= t_vy[size]; ly= t_ly[size]; sip= t_sip[size]; jsp= t_jsp[size]; ls= t_ls[size]; lp= t_lp[size]; if (is_function("unit_mode")==1) { metric = unit_mode(); if (!metric) { vy=vy/2.54; ly=ly/2.54; sip=sip/2.54; jsp=jsp/2.54; ls=ls/2.54; lp=lp/2.54; } } else { if (language == 0) { metric=2*pop_up("Units","Inches","Centimeters"); } if (metric<1) { vy=vy/2.54; ly=ly/2.54; sip=sip/2.54; jsp=jsp/2.54; ls=ls/2.54; lp=lp/2.54; } } if(metric==0) { sv=0.39; } read = 0; if (is_function("measure_table")==1) { if (measure_table("default_children")==1) { read = 1; } } if (read==0) { if (is_function("start_picture_input")) { if (language == 0) { start_picture_input("CHILD'S ELASTIC-WAIST PANTS"); } if (language == 0) { add_picture_input("Waist circumference", vy, "bc_meas_waistcirc"); } if (language == 0) { add_picture_input("Hip circumference",ly, "bc_meas_hipcirc"); } if (language == 0) { add_picture_input("Outside length", sip, "bc_meas_outside"); } if (language == 0) { add_picture_input("Inside length", jsp, "bc_meas_inside"); } if (language == 0) { add_picture_input("Seam Allowance", sv, "meas_seamallow"); } run_picture_input(); } else { if (language == 0) { dialog_box("CHILD'S ELASTIC-WAIST PANTS", "Waist circumference", vy, "Hip circumference",ly, "Outside length", sip, "Inside length", jsp, "Seam Allowance", sv); } } } else { if (is_function("start_picture_input")) { if (language == 0) { start_picture_input("CUSTOM MEASUREMENTS"); } if (language == 0) { add_picture_input("Seam Allowance", sv, "meas_seamallow"); } run_picture_input(); } else { if (language == 0) { dialog_box("CUSTOM MEASUREMENTS", "Seam Allowance", sv); } } } if (is_function("unit_mode")==1) { metric = unit_mode(); if (!metric) { vy=vy*2.54; ly=ly*2.54; sip=sip*2.54; jsp=jsp*2.54; ls=ls*2.54; lp=lp*2.54; } } else { if (metric<1) { vy=vy*2.54; ly=ly*2.54; sip=sip*2.54; jsp=jsp*2.54; ls=ls*2.54; lp=lp*2.54; } } if(metric==2) { sv=sv/2.54; } vy= vy+2+20; ly= ly+4+8; ls=ls+10; ik=sip-jsp; lx=ly/20; polvi=jsp/2+jsp/10; x[0]=0; y[0]=30; coord(0,1,0,0); coord(1,2,0,-sip); coord(2,3,0,jsp); coord(3,4,0,ik/3); coord(2,5,0,2); coord(4,6,-(ly/8-1.5),0); coord(4,7,(ly/8+1.5+2),0); x[8]=x[6]; y[8]=y[3]; x[9]=x[8]; y[9]=y[1]; coord(9,10,(vy/4+1),0); coord(8,11,-(lx+1),0); coord(5,12,-(ls/4-0.75),0); coord(5,112,(ls/4-0.75),0); coord(4,13,0,(lx+2)); coord(13,14,-lx,0); coord(14,15,sqrt((ly/4+2)*(ly/4+2)-(lx+2)*(lx+2)),-(lx+2)); coord(6,106,2,0); cont(106,14,116,50); coord(12,20,-1.5,0); coord(112,120,1.5,0); cont(120,15,117,(dist(7,10)/2)); cont(15,117,217,(dist(7,10)/2)); x[17]=x[217]-1; y[17]=y[1]; cont(116,14,16,-dist(15,217)); coord(11,18,-(lx+1),0); coord(18,19,0,0); coord(11,119,0,0); coord(8,108,0,0); center(16,17,21); cont(17,21,24,-((dist(16,17)-(vy/4-1))/2)); cont(17,21,23,+((dist(16,17)-(vy/4-1))/2)); cont(14,16,114,-8); cont(117,114,22,-dist(16,21)); center(7,10,110); coord(1,101,2.5,0); cont(101,10,210,-7); x[211]=x[210]; y[211]=y[110]; cont(26,7,213,-5); x[212]=x[1]; y[212]=y[213]-3; group_obj[0] = newobject("poly"); addpoint((x[1]-vy/2)/2.54, (y[1])/2.54, "line"); addpoint((x[1]+2.5-vy/2)/2.54, (y[1])/2.54, "line"); addpoint((x[10]-vy/2)/2.54, (y[10])/2.54, "line"); addpoint((x[110]-vy/2)/2.54, (y[110])/2.54, "line"); addpoint((x[7]-vy/2)/2.54, (y[7])/2.54, "xarc_start"); addpoint((x[212]-vy/2)/2.54, (y[212])/2.54, "xarc_corner"); group_obj[1]=newobject("poly"); addpoint((x[1]+5-vy/2)/2.54, (y[210]-2)/2.54, "line"); addpoint((x[1]+5-vy/2)/2.54, (y[7])/2.54, "open"); group_obj[2]=newobject("poly"); addpoint((x[1]-vy/2)/2.54, (y[1]-20)/2.54, "line"); addpoint((x[1]+2.5-vy/2)/2.54, (y[1]-20)/2.54, "line"); addpoint((x[210]-vy/2)/2.54, (y[210]-20)/2.54, "xarc_start"); addpoint((x[211]-vy/2)/2.54, (y[211]-20)/2.54, "xarc_corner"); addpoint((x[110]-vy/2)/2.54, (y[110]-20)/2.54, "line"); addpoint((x[7]-vy/2)/2.54, (y[7]-20)/2.54, "xarc_start"); addpoint((x[212]-vy/2)/2.54, (y[212]-20)/2.54, "xarc_corner"); group_obj[3]=newobject("poly"); addpoint((x[1]+5-vy/2)/2.54, (y[110]-20)/2.54, "line"); addpoint((x[1]+5-vy/2)/2.54, (y[7]-20)/2.54, "open"); group_obj[4]=newobject("poly"); addpoint((x[1])/2.54, (y[1])/2.54, "line"); addpoint((x[210])/2.54, (y[210])/2.54, "xarc_start"); addpoint((x[211])/2.54, (y[211])/2.54, "xarc_corner"); addpoint((x[110])/2.54, (y[110])/2.54, "xarc_corner"); addpoint((x[7])/2.54, (y[7])/2.54, "line"); addpoint((x[112])/2.54, (y[112])/2.54, "line"); addpoint((x[5])/2.54, (y[5])/2.54, "line"); addpoint((x[12])/2.54, (y[12])/2.54, "line"); addpoint((x[11])/2.54, (y[11])/2.54, "xarc_start"); addpoint((x[8])/2.54, (y[8])/2.54, "xarc_corner"); addpoint((x[6])/2.54, (y[6])/2.54, "line"); addpoint((x[9])/2.54, (y[9])/2.54, "line"); group_obj[5]=newobject("poly"); addpoint((x[5])/2.54, y[5]/2.54, "line"); addpoint((x[1])/2.54, y[1]/2.54, "line"); group_obj[6]=newobject("poly"); addpoint((x[16]+ly/2)/2.54, (y[16])/2.54, "line"); addpoint((x[17]+ly/2)/2.54, (y[17])/2.54, "xarc_start"); addpoint((x[117]+ly/2)/2.54, (y[117])/2.54, "xarc_corner"); addpoint((x[15]+ly/2)/2.54, (y[15])/2.54, "line"); addpoint((x[120]+ly/2)/2.54, (y[120])/2.54, "line"); addpoint((x[5]+ly/2)/2.54, (y[5])/2.54, "line"); addpoint((x[20]+ly/2)/2.54, (y[20])/2.54, "xarc_start"); center(19,20,121); x[121]=x[121]+2; addpoint((x[121]+ly/2)/2.54, (y[121])/2.54, "xarc_corner"); addpoint((x[19]+ly/2)/2.54, (y[19])/2.54, "line"); addpoint((x[119]+ly/2)/2.54, (y[119])/2.54, "xarc_start"); addpoint((x[108]+ly/2)/2.54, (y[108])/2.54, "xarc_corner"); addpoint((x[14]+ly/2)/2.54, (y[14])/2.54, "line"); group_obj[7]=newobject("poly"); addpoint((x[5]+ly/2)/2.54, (y[5])/2.54, "line"); addpoint((x[5]+ly/2)/2.54, (y[16]-1)/2.54, "line"); coord(20,1,0,-5); coord(1,2,vy,0); coord(2,3,0,-6); coord(1,4,0,-6); group_obj[8]=newobject("poly"); addpoint((x[1])/2.54, (y[1])/2.54, "line"); addpoint((x[2])/2.54, (y[2])/2.54, "line"); addpoint((x[3])/2.54, (y[3])/2.54, "line"); addpoint((x[4])/2.54, (y[4])/2.54, "line"); if (sv!=0) { //pocket offset_mark(0); select(current_selection,group_obj[1]); group(current_selection); deselect(current_selection); //pocket offset_mark(2); select(current_selection,group_obj[3]); group(current_selection); deselect(current_selection); //front offset_mark(4); select(current_selection,group_obj[5]); group(current_selection); deselect(current_selection); //front offset_mark(6); select(current_selection,group_obj[7]); group(current_selection); deselect(current_selection); //front offset_mark(8); group(current_selection); deselect(current_selection); } else { //pocket mark(0); current_selection=newselection("OBJECT"); select(current_selection,group_obj[0]); select(current_selection,group_obj[1]); group(current_selection); deselect(current_selection); //pocket mark(2); current_selection=newselection("OBJECT"); select(current_selection,group_obj[2]); select(current_selection,group_obj[3]); group(current_selection); deselect(current_selection); //front mark(4); current_selection=newselection("OBJECT"); select(current_selection,group_obj[4]); select(current_selection,group_obj[5]); group(current_selection); deselect(current_selection); //front mark(6); current_selection=newselection("OBJECT"); select(current_selection,group_obj[6]); select(current_selection,group_obj[7]); group(current_selection); deselect(current_selection); //front mark(8); } current_selection=newselection("OBJECT"); for (loop = 0; loop < 20; loop = loop + 1) { if (marker_array[loop] != 0) { select(current_selection, marker_array[loop]); } } check_overlap(current_selection); if (is_function("origin_arrange")==1) { origin_arrange(current_selection); } deselect(current_selection); if (is_function("set_marker")==1) { for (loop = 0; loop < 20; loop = loop + 1) { if (marker_array[loop] != 0) { set_marker(marker_array[loop], 0); } } } run_command("zoomall"); } newobj_dot() { line("CENTER_LINE"); NEWOBJECT ("POLY"); line("SOLID_LINE"); } coord(double orig, double dest, double xxx, double yyy) { x[dest]=x[orig]+xxx; y[dest]=y[orig]+yyy; } center(double one, double two, double result) { x[result]=(x[one]+x[two])/2; y[result]=(y[one]+y[two])/2; } dist(double p1, double p2) { return distance(x[p1],y[p1],x[p2],y[p2]); } line_intersect(double start1, double end1, double start2, double end2, double dest) { double tempx; double tempy; intersect(x[start1],y[start1],x[end1],y[end1],x[start2],y[start2],x[end2],y[end2],0); x[dest]=getresultx(); y[dest]=getresulty(); } cont(double cstart, double cend, double cdest, double cvdistanceance) { double ang; ang=angle(x[cstart], y[cstart], x[cend], y[cend]); polar(x[cend], y[cend], ang, cvdistanceance); x[cdest]=getresultx(); y[cdest]=getresulty(); } right_ang(double start, double end, double to_point, double dest) { double m,b; if (x[start]==x[end]) { x[dest]=x[end]; y[dest]=y[to_point]; } else { if (y[start]==y[end]) { x[dest]=x[to_point]; y[dest]=y[end]; } else { m=(y[start]-y[end])/(x[start]-x[end]); m=-1/m; b=y[to_point]-m*x[to_point]; intersect(x[start],y[start],x[end],y[end],x[to_point],y[to_point],0,b,0); x[dest]=getresultx(); y[dest]=getresulty(); } } } mark(double pass_index) { group_obj[pass_index]=marker_piece(group_obj[pass_index],1); marker_array[marker_count] = group_obj[pass_index]; marker_count = marker_count + 1; } offset_mark(double pass_index) { point pnt, test; double save_x, save_y; current_selection=newselection("OBJECT"); select(current_selection,group_obj[pass_index]); sel_push(current_selection); var_push(sv); run_command("OFFSET"); deselect(current_selection); current_object=last_obj(); marker_array[marker_count] = marker_piece(current_object,1); current_selection=newselection("OBJECT"); select(current_selection, marker_array[marker_count]); select(current_selection, group_obj[pass_index]); marker_count = marker_count + 1; } Forward() { index = index + 1; if ( (index == 1) && (unit_mode() == 1) ) { index = index + 1; } if ( (index == 2) && (unit_mode() == 0) ) { index = index + 1; } if (index == 3) { done = 1; } } Backward() { index = index - 1; } Popup1() { if (language == 0) { start_pict_dialog("CHOOSE MEASUREMENT UNITS"); add_pict_item("Child's height in inches","blank.jpg"); add_pict_item("Child's height in centimeters","blank.jpg"); run_pict("Next"); sizes=get_pict_result(); Forward(); } } Popup2() { if (language == 0) { start_pict_dialog("SELECT CLOSEST HEIGHT"); add_pict_item("41","blank.jpg"); add_pict_item("43","blank.jpg"); add_pict_item("45.5","blank.jpg"); add_pict_item("48","blank.jpg"); add_pict_item("50.5","blank.jpg"); add_pict_item("53","blank.jpg"); add_pict_item("55","blank.jpg"); add_pict_item("57.5","blank.jpg"); run_pict("Next"); size=get_pict_result(); Forward(); } } Popup3() { if (language == 0) { start_pict_dialog("SELECT CLOSEST HEIGHT"); add_pict_item("104","blank.jpg"); add_pict_item("110","blank.jpg"); add_pict_item("116","blank.jpg"); add_pict_item("122","blank.jpg"); add_pict_item("128","blank.jpg"); add_pict_item("134","blank.jpg"); add_pict_item("140","blank.jpg"); add_pict_item("146","blank.jpg"); run_pict("Next"); size=get_pict_result(); Forward(); } } shift(double orig, double xxx, double yyy) { x[orig]=x[orig]+xxx; y[orig]=y[orig]+yyy; } rect (double x1, double y1, double x2, double y2) { newobject("poly"); addpoint( x1/2.54,y1/2.54,"LINE"); addpoint( x2/2.54,y1/2.54,"LINE"); addpoint( x2/2.54,y2/2.54,"LINE"); addpoint( x1/2.54,y2/2.54,"LINE"); } dot (double x, double y) { newobject("poly"); addpoint( x/2.54,y/2.54,"LINE"); } line (double x3, double y3, double x4, double y4) { newobject("poly"); addpoint( x3/2.54,y3/2.54,"LINE"); addpoint( x4/2.54,y4/2.54,"LINE"); } rotate(double rpoint,double rcenter, double rangle) { double vdistance, vang; vdistance=dist(rpoint, rcenter); vang=angle(x[rcenter],y[rcenter],x[rpoint],y[rpoint]); polar(x[rcenter],y[rcenter],vang+rangle,vdistance); x[rpoint]=getresultx(); y[rpoint]=getresulty(); } linecirc(double PA,double PB,double PC,double dradius,double which, double PD) { double mslope, dist0, dist1, dist2, xtemp; double tx, ty; xtemp = (x[PB]-x[PC])*(x[PB]-x[PC]); if (xtemp > 0) { xtemp = (y[PB]-y[PC])*(y[PB]-y[PC]); if ( xtemp > 0) { mslope = (y[PC] - y[PB])/(x[PC] - x[PB]); tx = x[PA] + 1; ty = y[PA] - 1/mslope; intersect(x[PA], y[PA], tx, ty, x[PB], y[PB], x[PC], y[PC], 0); tx = getresultx(); ty = getresulty(); dist1 = distance(x[PA], y[PA], tx, ty); dist2 = interceptline(0, dist1, dradius); dist0 = sqrt(1+mslope*mslope); xtemp = dist2/dist0; if (which) { x[PD] = tx+xtemp; y[PD] = ty+ xtemp*mslope; } else { x[PD] = tx-xtemp; y[PD] = ty- xtemp*mslope; } } else { x[PD] = x[PB]; if (which) { y[PD] = y[PA] + interceptline(x[PA], x[PB], dradius); } else { y[PD] = y[PA] - interceptline(x[PA], x[PB], dradius); } } } else { y[PD] = y[PB]; if (which) { x[PD] = x[PA] + interceptline(y[PA], y[PB], dradius); } else { x[PD] = x[PA] - interceptline(y[PA], y[PB], dradius); } } } double xar[13], yar[13]; double save_rx, save_ry; arclength(double start, double corner, double end) { double ct, last_x, last_y; double a_dist; last_x = x[start]; last_y = y[start]; a_dist=0; for (ct=1; ct < 12; ct = ct + 1) { fts(start, corner, end, ct); a_dist = a_dist + distance(save_rx, save_ry, last_x, last_y); last_x=save_rx; last_y=save_ry; } return a_dist; } double A1, A2, B1, B2; double sx, sy, cx, cy, ex, ey; double t0[2], t1[2]; double ftc[2]; fts(double start, double corner, double end, double pos) { if (pos<1) { save_rx=x[start]; save_ry=y[start]; } else { if (pos<2) { sx = x[start]; sy = y[start]; cx = x[corner]; cy = y[corner]; ex = x[end]; ey = y[end]; A1=cx - sx; A2=cy - sy; B1=cx - ex; B2=cy - ey; A1=-A1; B1=-B1; A2=-A2; B2=-B2; t0[0]=A1; t0[1]=B1; t1[0]=A2; t1[1]=B2; ftc[0]= cx + (t0[0] + t0[1]); ftc[1]= cy + (t1[0] + t1[1]); save_rx = t0[0]*(xar[pos])+t0[1]*(yar[pos])+ ftc[0]; save_ry = t1[0]*(xar[pos])+t1[1]*(yar[pos])+ ftc[1]; } else { if (pos>10) { save_rx=x[end]; save_ry=y[end]; } else { save_rx = t0[0]*(xar[pos])+t0[1]*(yar[pos])+ ftc[0]; save_ry = t1[0]*(xar[pos])+t1[1]*(yar[pos])+ ftc[1]; } } } } init_xarc_array() { double ang_start, ang_end, step, theta, ct; double XARC_PIECES; XARC_PIECES = 12; ang_start = -3.14159/2; ang_end= -3.14159; ct=0; step= (ang_end - ang_start)/(XARC_PIECES-1); for (theta=ang_start; ct < XARC_PIECES; theta = theta + step) { xar[ct] = cos(theta); yar[ct] = sin(theta); ct=ct+1; } } max(double aa, double bb) { if (aa > bb) { return aa; } else { return bb; } } min(double aa, double bb) { if (aa < bb) { return aa; } else { return bb; } }