public GerberHIDAttribute(GerberHIDAttribute attibute) { Name = attibute.Name; HelpText = attibute.HelpText; HIDType = attibute.HIDType; MinValue = attibute.MinValue; MaxValue = attibute.MaxValue; Enumerations = attibute.Enumerations; Value = attibute.Value; Hash = attibute.Hash; }
private static void CreateDefaultAttributeList() { // Initialize the default attributes. GerberHIDAttribute attribute = null; attribute = new GerberHIDAttribute(); attribute.Name = "autodetect"; attribute.HelpText = "Try to autodetect the format."; attribute.HIDType = GerberHIDType.Boolean; attribute.MinValue = 0; attribute.MaxValue = 0; attribute.DefaultValue = new HIDAttributeValue(1, null, 0); attribute.Enumerations = null; attribute.Value = IntPtr.Zero; drillAttributeList.Add(attribute); attribute = new GerberHIDAttribute(); attribute.Name = "zero_suppession"; attribute.HelpText = "Zero suppression."; attribute.HIDType = GerberHIDType.Enumeration; attribute.MinValue = 0; attribute.MaxValue = 0; attribute.DefaultValue = new HIDAttributeValue(0, null, 0); attribute.Enumerations = supressionList; attribute.Value = IntPtr.Zero; drillAttributeList.Add(attribute); attribute = new GerberHIDAttribute(); attribute.Name = "units"; attribute.HelpText = "Units."; attribute.HIDType = GerberHIDType.Enumeration; attribute.MinValue = 0; attribute.MaxValue = 0; attribute.DefaultValue = new HIDAttributeValue(0, null, 0); attribute.Enumerations = unitsList; attribute.Value = IntPtr.Zero; drillAttributeList.Add(attribute); attribute = new GerberHIDAttribute(); attribute.Name = "tool_units"; attribute.HelpText = "Tool size units."; attribute.HIDType = GerberHIDType.Enumeration; attribute.MinValue = 0; attribute.MaxValue = 0; attribute.DefaultValue = new HIDAttributeValue(1, null, 0); attribute.Enumerations = unitsList; attribute.Value = IntPtr.Zero; drillAttributeList.Add(attribute); attribute = new GerberHIDAttribute(); attribute.Name = "digits"; attribute.HelpText = "Number of digits. For trailing zero supression," + "this is the number of digits before the decimal point. " + "Otherwise this is the number of digits after the decimal point."; attribute.HIDType = GerberHIDType.Integer; attribute.MinValue = 0; attribute.MaxValue = 0; attribute.DefaultValue = new HIDAttributeValue(5, null, 0); attribute.Enumerations = null; attribute.Value = IntPtr.Zero; drillAttributeList.Add(attribute); }
private static List <GerberHIDAttribute> drillAttributeList = new List <GerberHIDAttribute>(); /* <---- NOT SURE IF WE NEED THIS.*/ public static GerberImage ParseDrillFile(string drillFileName, List <GerberHIDAttribute> attributeList, int numberOfAttributes, bool reload) { bool foundEOF = false; string errorMessage = String.Empty; DrillState drillState = new DrillState(); GerberImage image = new GerberImage("Excellon Drill File"); CreateDefaultAttributeList(); if (reload & attributeList != null) { image.ImageInfo.NumberOfAttribute = numberOfAttributes; image.ImageInfo.AttributeList = new List <GerberHIDAttribute>(); for (int i = 0; i < numberOfAttributes; i++) { GerberHIDAttribute attribute = new GerberHIDAttribute(attributeList[i]); image.ImageInfo.AttributeList.Add(attribute); } } else { // Load default attributes. image.ImageInfo.NumberOfAttribute = drillAttributeList.Count; image.ImageInfo.AttributeList = new List <GerberHIDAttribute>(); for (int i = 0; i < image.ImageInfo.NumberOfAttribute; i++) { GerberHIDAttribute attribute = new GerberHIDAttribute(drillAttributeList[i]); image.ImageInfo.AttributeList.Add(attribute); } } DrillAttributeMerge(image.ImageInfo.AttributeList, image.ImageInfo.NumberOfAttribute, attributeList, numberOfAttributes); image.FileType = GerberFileType.Drill; image.DrillStats = new DrillFileStats(); image.Format = new GerberFormat(); image.Format.OmitZeros = GerberOmitZero.OmitZerosUnspecified; if (image.ImageInfo.AttributeList[(int)HA.AutoDetect].DefaultValue.IntValue > 0) { drillState.AutoDetect = false; drillState.DataNumberFormat = DrillNumberFormat.UserDefined; drillState.DecimalPlaces = image.ImageInfo.AttributeList[(int)HA.Digits].DefaultValue.IntValue; if (image.ImageInfo.AttributeList[(int)HA.ZeroSuppression].DefaultValue.IntValue == (int)Units.Millimeters) { drillState.Unit = GerberUnit.Millimeter; } switch (image.ImageInfo.AttributeList[(int)HA.ZeroSuppression].DefaultValue.IntValue) { case (int)ZeroSuppression.Leading: image.Format.OmitZeros = GerberOmitZero.OmitZerosLeading; break; case (int)ZeroSuppression.Trailing: image.Format.OmitZeros = GerberOmitZero.OmitZerosTrailing; break; default: image.Format.OmitZeros = GerberOmitZero.OmitZerosExplicit; break; } } //Debug.WriteLine(String.Format("Starting to parse drill file {0}", drillFileName)); using (StreamReader drillFileStream = new StreamReader(drillFileName, Encoding.ASCII)) { GerberLineReader lineReader = new GerberLineReader(drillFileStream); foundEOF = ParseDrillSegment(drillFileName, lineReader, image, drillState); } if (!foundEOF) { errorMessage = String.Format(CultureInfo.CurrentCulture, "File {0} is missing Excellon Drill EOF code./n", drillFileName); image.DrillStats.AddNewError(-1, errorMessage, GerberErrorType.GerberError); } //Debug.WriteLine("... done parsing Excellon Drill file."); return(image); }