private static void CreateBoardView(IStep step, IFilter filter, IODBLayer frontLayer, float boardThickness, bool front) { if (boardThickness > 0) { #region draw board front int shapeIndexBoardHeight = IFilter.AddToolDefinitionRect(frontLayer, boardThickness, boardThickness, boardThickness, false); //add line with board symbol index to have correct thickness IODBObject boardLineFront = filter.CreateLine(frontLayer); ILineSpecificsD lineDetails = (ILineSpecificsD)boardLineFront.GetSpecificsD(); if (front) { lineDetails.Start = new PointD(step.GetBoundsD().Left + boardThickness / 2, 0); lineDetails.End = new PointD(step.GetBoundsD().Right - boardThickness / 2, 0); } else { lineDetails.Start = new PointD(0, step.GetBoundsD().Top + boardThickness / 2); lineDetails.End = new PointD(0, step.GetBoundsD().Bottom - boardThickness / 2); } boardLineFront.SetSpecifics(lineDetails, shapeIndexBoardHeight); boardLineFront.ObjectColorTemporary(Color.Green); #endregion } }
public void Execute(IPCBIWindow parent) { IFilter filter = new IFilter(parent); IStep curStep = parent.GetCurrentStep(); if (curStep == null) { MessageBox.Show("No Job loaded, please load a job before start this script!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } IODBLayer fiducialLayer = filter.CreateEmptyODBLayer("fiducial", curStep.Name); if (fiducialLayer == null) { MessageBox.Show("Can't create new layer!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } // int shapeIndex = IFilter.AddToolDefinitionDonut(fiducialLayer, (float)IMath.MM2Mils(2),(float) IMath.MM2Mils(1), -1); // int shapeIndex = IFilter.AddToolDefinitionRound(fiducialLayer, (float)IMath.MM2Mils(2) -1); int shapeIndex = IFilter.AddToolDefinitionRect(fiducialLayer, (float)IMath.MM2Mils(2), -1, (float)IMath.MM2Mils(2), (float)IMath.MM2Mils(1), false); int shapeIndex2 = IFilter.AddToolDefinitionRect(fiducialLayer, (float)IMath.MM2Mils(1), -1, (float)IMath.MM2Mils(1), (float)IMath.MM2Mils(2), false); // if a cross we can use to rects to create a cross or make a surface IODBObject pad = filter.CreatePad(fiducialLayer); PointD FidPoint = new PointD(IMath.MM2Mils(3), IMath.MM2Mils(3)); pad.SetSpecifics(new IPadSpecificsD() { Location = FidPoint, ShapeIndex = shapeIndex, Positive = true }); IAttributeElement attribute = new IAttributeElement(PCBI.FeatureAttributeEnum.fiducial_name); attribute.Value = "fid1"; IAttribute.SetAttribute(attribute, pad); pad = filter.CreatePad(fiducialLayer); pad.SetSpecifics(new IPadSpecificsD() { Location = FidPoint, ShapeIndex = shapeIndex2, Positive = true }); attribute = new IAttributeElement(PCBI.FeatureAttributeEnum.fiducial_name); attribute.Value = "fid1"; IAttribute.SetAttribute(attribute, pad); FidPoint = new PointD(IMath.MM2Mils(3), IMath.MM2Mils(147)); pad = filter.CreatePad(fiducialLayer); pad.SetSpecifics(new IPadSpecificsD() { Location = FidPoint, ShapeIndex = shapeIndex, Positive = true }); attribute = new IAttributeElement(PCBI.FeatureAttributeEnum.fiducial_name); attribute.Value = "fid2"; IAttribute.SetAttribute(attribute, pad); pad = filter.CreatePad(fiducialLayer); pad.SetSpecifics(new IPadSpecificsD() { Location = FidPoint, ShapeIndex = shapeIndex2, Positive = true }); attribute = new IAttributeElement(PCBI.FeatureAttributeEnum.fiducial_name); attribute.Value = "fid2"; IAttribute.SetAttribute(attribute, pad); parent.UpdateControlsAndResetView(); }
private static void CreateComponents(bool top, ICMPLayer CMPLayer, IODBLayer frontLayer, IODBLayer sideLayer, float offset, IFilter filter, bool allValuesInMM) { if (CMPLayer == null) { return; } foreach (ICMPObject component in CMPLayer.GetAllLayerObjects()) { float height = (float)component.CompHEIGHT; IPackageSpecificsD usedPackage = component.GetPackageSpecificsD(); if (height == 0) { height = usedPackage.Height; } if (height == 0) { #region check height //check attributes foreach (string attrib in component.GetComponentAttributes()) { if (attrib.ToLowerInvariant().Contains("height")) { string[] attribtValueFinder = attrib.Split('='); if (attribtValueFinder.Length > 1) { float.TryParse(attribtValueFinder[1], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out height); } else if (attribtValueFinder[0].Contains("\'")) { string subStr = attribtValueFinder[0].Substring(attribtValueFinder[0].IndexOf('\'') + 1); if (subStr.Contains("\'")) { subStr = subStr.Substring(0, subStr.IndexOf('\'')); float.TryParse(subStr, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out height); } } } } #endregion } if (allValuesInMM) { height = (float)IMath.MM2Mils(height); } #region front layer int componentFront = IFilter.AddToolDefinitionRect(frontLayer, (float)component.Bounds.Width, height, (float)component.Bounds.Width, false); IODBObject cmpFront = filter.CreatePad(frontLayer); IPadSpecificsD padCMPFront = (IPadSpecificsD)cmpFront.GetSpecificsD(); if (top) { padCMPFront.Location = new PointD(component.Bounds.X + component.Bounds.Width / 2, offset + height / 2); } else { padCMPFront.Location = new PointD(component.Bounds.X + component.Bounds.Width / 2, -(offset + height / 2)); } cmpFront.SetSpecifics(padCMPFront, componentFront); cmpFront.FreeText = component.Ref; if (top) { cmpFront.ObjectColorTemporary(Color.Silver); } else { cmpFront.ObjectColorTemporary(Color.Gray); } #endregion #region side layer int componentSide = IFilter.AddToolDefinitionRect(sideLayer, (float)component.Bounds.Height, (float)component.Bounds.Height, height, false); IODBObject cmpSide = filter.CreatePad(sideLayer); IPadSpecificsD padCMPSide = (IPadSpecificsD)cmpSide.GetSpecificsD(); if (top) { padCMPSide.Location = new PointD(offset + height / 2, component.Bounds.Y + component.Bounds.Height / 2); } else { padCMPSide.Location = new PointD(-(offset + height / 2), component.Bounds.Y + component.Bounds.Height / 2); } cmpSide.SetSpecifics(padCMPSide, componentSide); cmpSide.FreeText = component.Ref; if (top) { cmpSide.ObjectColorTemporary(Color.Silver); } else { cmpSide.ObjectColorTemporary(Color.Gray); } #endregion } }