@@ -46,7 +46,7 @@ interface ICoordinates {
4646} 
4747
4848interface  IParentTransform  extends  ICoordinates  { 
49-  angle : number ; 
49+  angle : number | null ; 
5050} 
5151
5252function  kiUnits ( value : string  |  number )  { 
@@ -56,10 +56,12 @@ function kiUnits(value: string | number) {
5656 return  value  *  10  *  0.0254 ; 
5757} 
5858
59- function  kiAngle ( value : string ,  parentAngle ?: number )  { 
60-  const  angle  =  parseFloat ( value )  +  ( parentAngle  ||  0 ) ; 
61-  if  ( ! isNaN ( angle ) )  { 
62-  return  angle  >  180  ? - ( 360  -  angle )  : angle ; 
59+ function  kiAngle ( value ?: string ,  parentAngle ?: number )  { 
60+  if  ( value )  { 
61+  const  angle  =  parseFloat ( value )  +  ( parentAngle  ||  0 ) ; 
62+  if  ( ! isNaN ( angle ) )  { 
63+  return  angle  >  180  ? - ( 360  -  angle )  : angle ; 
64+  } 
6365 } 
6466 return  null ; 
6567} 
@@ -130,7 +132,7 @@ function convertVia(
130132 const  [ x ,  y ,  diameter ,  net ,  drill ,  id ,  locked ]  =  args ; 
131133 return  [ 
132134 'via' , 
133-  kiAt ( x ,  y ,  null ,  parentCoords ) , 
135+  kiAt ( x ,  y ,  undefined ,  parentCoords ) , 
134136 [ 'size' ,  kiUnits ( diameter ) ] , 
135137 [ 'drill' ,  kiUnits ( drill )  *  2 ] , 
136138 [ 'layers' ,  'F.Cu' ,  'B.Cu' ] , 
@@ -164,7 +166,6 @@ function convertPadToVia(
164166
165167 const  size  =  kiUnits ( holeRadius ) ; 
166168 const  drillHoleLength  =  holeLength  ===  '0'  ? null  : kiUnits ( holeLength ) ; 
167-  const  slotted  =  drillHoleLength  >  0  ? 'oval'  : null ; 
168169
169170 if  ( shape  !==  'ELLIPSE' )  { 
170171 return  [ 
@@ -182,7 +183,7 @@ function convertPadToVia(
182183
183184 return  [ 
184185 'via' , 
185-  kiAt ( x ,  y ,  null ,  parentCoords ) , 
186+  kiAt ( x ,  y ,  undefined ,  parentCoords ) , 
186187 [ 'size' ,  kiUnits ( holeRadius ) ] , 
187188 [ 'drill' ,  kiUnits ( drill )  *  2 ] , 
188189 [ 'layers' ,  'F.Cu' ,  'B.Cu' ] , 
@@ -291,9 +292,13 @@ function convertArc(
291292 transform ?: IParentTransform 
292293)  { 
293294 const  [ width ,  layer ,  net ,  path ,  _ ,  id ,  locked ]  =  args ; 
294-  const  [ match ,  startPoint ,  arcParams ]  =  / ^ M \s * ( [ - \d . \s ] + ) A \s * ( [ - \d . \s ] + ) $ / . exec ( 
295-  path . replace ( / [ , \s ] + / g,  ' ' ) 
296-  ) ; 
295+  const  pathMatch  =  / ^ M \s * ( [ - \d . \s ] + ) A \s * ( [ - \d . \s ] + ) $ / . exec ( path . replace ( / [ , \s ] + / g,  ' ' ) ) ; 
296+  if  ( ! pathMatch )  { 
297+  console . warn ( `Invalid arc path: ${ path }  ` ) ; 
298+  return  null ; 
299+  } 
300+ 301+  const  [ match ,  startPoint ,  arcParams ]  =  pathMatch ; 
297302 const  [ startX ,  startY ]  =  startPoint . split ( ' ' ) ; 
298303 const  [ svgRx ,  svgRy ,  xAxisRotation ,  largeArc ,  sweep ,  endX ,  endY ]  =  arcParams . split ( ' ' ) ; 
299304 const  start  =  kiCoords ( startX ,  startY ,  transform ) ; 
@@ -438,7 +443,7 @@ function convertLibHole(args: string[], transform: IParentTransform) {
438443 '' , 
439444 'np_thru_hole' , 
440445 'circle' , 
441-  kiAt ( x ,  y ,  null ,  transform ) , 
446+  kiAt ( x ,  y ,  undefined ,  transform ) , 
442447 [ 'size' ,  size ,  size ] , 
443448 [ 'drill' ,  size ] , 
444449 [ 'layers' ,  '*.Cu' ,  '*.Mask' ] , 
@@ -687,7 +692,7 @@ export function convertShape(shape: string, conversionState: IConversionState) {
687692} 
688693
689694function  flatten < T > ( arr : T [ ] )  { 
690-  return  [ ] . concat ( ...arr ) ; 
695+  return  ( [ ] as T [ ] ) . concat ( ...arr ) ; 
691696} 
692697
693698export  function  convertBoardToArray ( input : IEasyEDABoard ) : ISpectraList  { 
0 commit comments