/// <summary> /// Toggle rule on/off. /// </summary> /// <param name="RuleName">Name of rule to toggle</param> public void ToggleDesignRule(string RuleName) { try { IPCB_Rule Rule; IPCB_Board Board = Util.GetCurrentPCB(); if (Board == null) { return; } Rule = GetRule(RuleName); if (Rule == null) { MessageBox.Show("No rule found that matches '" + RuleName + "'."); return; } PCBServer.PreProcess(); Rule.BeginModify(); // {Rule has to be prepared for modification} Rule.SetState_DRCEnabled(!Rule.GetState_DRCEnabled()); // Toggle rule state. Rule.EndModify(); // {Let script know we are done modifying the rule} Rule = null; PCBServer.PostProcess(); //{Dispatch message to system now that processing is complete} Board.DispatchMessage(SCH.SCHConstant.FromSystem, SCH.SCHConstant.BroadCast, SCH.SCHConstant.SCHMYieldToRobots, SCH.SCHConstant.NoEventData); } catch (Exception ex) { ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex); } }
private void AddCenterMark() { IPCB_ServerInterface PcbServer = PCB.GlobalVars.PCBServer; if (PcbServer == null) { return; } IPCB_Library PcbLib = PcbServer.GetCurrentPCBLibrary(); if (PcbLib == null) { return; } IPCB_LibraryIterator LibIteartor = PcbLib.LibraryIterator_Create(); LibIteartor.AddFilter_ObjectSet(new PCB.TObjectSet(PCB.TObjectId.eComponentObject)); IPCB_LibComponent PcbCmp = LibIteartor.FirstPCBObject() as IPCB_LibComponent; while (PcbCmp != null) { IPCB_Board currentBoard = PcbServer.GetCurrentPCBBoard(); int Origin_X = currentBoard.GetState_XOrigin(); int Origin_Y = currentBoard.GetState_YOrigin(); int LineWidth = EDP.Utils.MMsToCoord((double)0.1); int HalfLineLegnth = EDP.Utils.MMsToCoord((double)0.5); V7_Layer MechLayer15 = new V7_Layer().Mechanical15(); PcbServer.PreProcess(); IPCB_Track vLine = PcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_Default) as IPCB_Track; SetTrackLocaton(vLine, Origin_X - HalfLineLegnth, Origin_Y, Origin_X + HalfLineLegnth, Origin_Y); vLine.SetState_Layer((int)MechLayer15.ID); vLine.SetState_Width(LineWidth); IPCB_Track hLine = PcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_Default) as IPCB_Track; SetTrackLocaton(hLine, Origin_X, Origin_Y + HalfLineLegnth, Origin_X, Origin_Y - HalfLineLegnth); hLine.SetState_Layer((int)MechLayer15.ID); hLine.SetState_Width(LineWidth); currentBoard.AddPCBObject(vLine); currentBoard.AddPCBObject(hLine); PcbServer.PostProcess(); DXP.Utils.RunCommand("PCB:Zoom", "Action=Redraw"); PcbCmp = LibIteartor.NextPCBObject() as IPCB_LibComponent; } PcbLib.LibraryIterator_Destroy(ref LibIteartor); }
private void DrawAreaAsCourtyard(PrimitiveArea Area, IPCB_ServerInterface ArgPcbServer, IPCB_Board ArgPcbBoard) { int CourtyardClearnce_IPC_L = EDP.Utils.MMsToCoord((double)0.1); int lineWidth = EDP.Utils.MMsToCoord((double)0.05); V7_Layer MechLayer15 = new V7_Layer().Mechanical15(); ArgPcbServer.PreProcess(); IPCB_Track trackLeft = ArgPcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_GlobalCopy) as IPCB_Track; SetTrackLocaton(trackLeft, Area.BottomLeft.X - CourtyardClearnce_IPC_L, Area.BottomLeft.Y - CourtyardClearnce_IPC_L, Area.TopLeft.X - CourtyardClearnce_IPC_L, Area.TopLeft.Y + CourtyardClearnce_IPC_L); trackLeft.SetState_Width(lineWidth); trackLeft.SetState_Layer((int)MechLayer15.ID); IPCB_Track trackRight = ArgPcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_GlobalCopy) as IPCB_Track; SetTrackLocaton(trackRight, Area.BottomRight.X + CourtyardClearnce_IPC_L, Area.BottomRight.Y - CourtyardClearnce_IPC_L, Area.TopRight.X + CourtyardClearnce_IPC_L, Area.TopRight.Y + CourtyardClearnce_IPC_L); trackRight.SetState_Width(lineWidth); trackRight.SetState_Layer((int)MechLayer15.ID); IPCB_Track trackTop = ArgPcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_GlobalCopy) as IPCB_Track; SetTrackLocaton(trackTop, Area.TopLeft.X - CourtyardClearnce_IPC_L, Area.TopLeft.Y + CourtyardClearnce_IPC_L, Area.TopRight.X + CourtyardClearnce_IPC_L, Area.TopRight.Y + CourtyardClearnce_IPC_L); trackTop.SetState_Width(lineWidth); trackTop.SetState_Layer((int)MechLayer15.ID); IPCB_Track trackBottom = ArgPcbServer.PCBObjectFactory(PCB.TObjectId.eTrackObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_GlobalCopy) as IPCB_Track; SetTrackLocaton(trackBottom, Area.BottomLeft.X - CourtyardClearnce_IPC_L, Area.BottomLeft.Y - CourtyardClearnce_IPC_L, Area.BottomRight.X + CourtyardClearnce_IPC_L, Area.BottomRight.Y - CourtyardClearnce_IPC_L); trackBottom.SetState_Width(lineWidth); trackBottom.SetState_Layer((int)MechLayer15.ID); ArgPcbBoard.AddPCBObject(trackBottom); ArgPcbBoard.AddPCBObject(trackLeft); ArgPcbBoard.AddPCBObject(trackRight); ArgPcbBoard.AddPCBObject(trackTop); ArgPcbServer.PostProcess(); DXP.Utils.RunCommand("PCB:Zoom", "Action=Redraw"); }
/// <summary> /// Adds a new track to the PCB /// </summary> /// <param name="Offset"></param> /// <param name="argWidth"></param> private void AddTrack(structPos Offset, int argWidth)//, V7_Layer argLayer) { PCBServer = PCB.GlobalVars.PCBServer; if (Offset.x == null) { Offset.x = 0; } if (Offset.y == null) { Offset.y = 0; } int xL, yL, xO, yO; IPCB_Board pcbBoard = Util.GetCurrentPCB(); if (pcbBoard == null) { return; } System.Diagnostics.Debug.WriteLine(pcbBoard.GetState_DisplayUnit().ToString()); TV6_Layer ActiveLayer = pcbBoard.GetState_CurrentLayer(); int OriginX = pcbBoard.GetState_XOrigin(); int OriginY = pcbBoard.GetState_YOrigin(); PCBServer.PreProcess(); // Set the value of J to point to the "next" vertex; this is normally // I + 1, but needs to be set to 0 instead for the very last vertex // that is processed by this loop. IPCB_Primitive primitive = PCBServer.PCBObjectFactory(TObjectId.eTrackObject, TDimensionKind.eNoDimension, TObjectCreationMode.eCreate_Default); if (primitive == null) { return; } IPCB_Track track = primitive as IPCB_Track; if (pcbBoard.GetState_DisplayUnit() == TUnit.eImperial) { xL = EDP.Utils.MilsToCoord((double)LastPos.x); yL = EDP.Utils.MilsToCoord((double)LastPos.y); xO = EDP.Utils.MilsToCoord((double)Offset.x); yO = EDP.Utils.MilsToCoord((double)Offset.y); argWidth = EDP.Utils.MilsToCoord((double)argWidth); } else { xL = EDP.Utils.MMsToCoord((double)LastPos.x); yL = EDP.Utils.MMsToCoord((double)LastPos.y); xO = EDP.Utils.MMsToCoord((double)Offset.x); yO = EDP.Utils.MMsToCoord((double)Offset.y); argWidth = EDP.Utils.MMsToCoord((double)argWidth); } if (Offset.absolute) { track.SetState_X1(OriginX + xL); track.SetState_Y1(OriginY + yL); track.SetState_X2(OriginX + xO); track.SetState_Y2(OriginY + yO); LastPos = Offset; } else { track.SetState_X1(OriginX + xL); track.SetState_Y1(OriginY + yL); track.SetState_X2(OriginX + (xL + xO)); track.SetState_Y2(OriginY + (yL + yO)); LastPos.x = LastPos.x + Offset.x; LastPos.y = LastPos.y + Offset.y; } track.SetState_Layer(ActiveLayer); track.SetState_Width(argWidth); pcbBoard.AddPCBObject(primitive); PCBServer.PostProcess(); // Refresh PCB workspace. //DXP.Utils.RunCommand("PCB:Zoom", "Action=Redraw"); }
private void CleanUpSamtecFootprints() { IPCB_ServerInterface PcbServer = PCB.GlobalVars.PCBServer; if (PcbServer == null) { return; } IPCB_Library PcbLib = PcbServer.GetCurrentPCBLibrary(); if (PcbLib == null) { return; } IPCB_LibraryIterator LibIteartor = PcbLib.LibraryIterator_Create(); LibIteartor.AddFilter_ObjectSet(new PCB.TObjectSet(PCB.TObjectId.eComponentObject)); IPCB_LibComponent PcbCmp = LibIteartor.FirstPCBObject() as IPCB_LibComponent; PcbServer.PreProcess(); while (PcbCmp != null) { IPCB_Board currentBoard = PcbServer.GetCurrentPCBBoard(); // heads up, PCB Ojbect can be added only by IPCB_Board, not IPCB_Component IPCB_GroupIterator PcbObjItera = PcbCmp.GroupIterator_Create(); IPCB_Primitive PcbObj = PcbObjItera.FirstPCBObject(); while (PcbObj != null) { switch (PcbObj.GetState_ObjectID()) { case PCB.TObjectId.eTrackObject: if ((int)PcbObj.GetState_V7Layer().ID != (int)new V7_Layer().Mechanical1().ID) { PcbObj = PcbObjItera.NextPCBObject(); continue; } IPCB_Track TrackObj = PcbObj as IPCB_Track; TrackObj.SetState_Width(EDP.Utils.MMsToCoord((double)0.1)); TrackObj.SetState_Layer((int)new V7_Layer().Mechanical13().ID); break; case PCB.TObjectId.eArcObject: if ((int)PcbObj.GetState_V7Layer().ID != (int)new V7_Layer().Mechanical1().ID) { PcbObj = PcbObjItera.NextPCBObject(); continue; } IPCB_Arc ArcObj = PcbObj as IPCB_Arc; ArcObj.SetState_LineWidth(EDP.Utils.MMsToCoord((double)0.1)); ArcObj.SetState_Layer((int)new V7_Layer().Mechanical13().ID); break; case PCB.TObjectId.eComponentBodyObject: IPCB_ComponentBody BodyObj = PcbObj as IPCB_ComponentBody; BodyObj.SetState_Layer((int)new V7_Layer().Mechanical13().ID); break; case PCB.TObjectId.eTextObject: PcbCmp.RemovePCBObject(PcbObj); break; } PcbObj = PcbObjItera.NextPCBObject(); } PcbServer.PostProcess(); DXP.Utils.RunCommand("PCB:Zoom", "Action=Redraw"); PcbCmp.GroupIterator_Destroy(ref PcbObjItera); PcbCmp = LibIteartor.NextPCBObject() as IPCB_LibComponent; } PcbLib.LibraryIterator_Destroy(ref LibIteartor); }
private void btnPlace_Click(object sender, EventArgs e) { try { clsSelectedObjects NewPlacement = new clsSelectedObjects(); Dictionary <string, string> NetCompare = GetNetDiff(); IPCB_Board brd = Util.GetCurrentPCB(); brd.SelectedObjects_Clear(); IPCB_Primitive temp; IPCB_ServerInterface PCBServer = PCB.GlobalVars.PCBServer; PCBServer.PreProcess(); int OffsetX = 0, OffsetY = 0; if (!brd.ChooseLocation(ref OffsetX, ref OffsetY, "Select placement location")) { return; } try { OffsetX = OffsetX - PR.selectedSourceObjects.componentObjects[0].GetState_XLocation(); OffsetY = OffsetY - PR.selectedSourceObjects.componentObjects[0].GetState_YLocation(); } catch (Exception ex) { if (ex.HResult == -2147467259) { MessageBox.Show("Source and destination data is corrupted due to board file being closed. Please restart the process."); lstDest.Items.Clear(); lstSource.Items.Clear(); lstMatched.Items.Clear(); return; } throw; } PR.GetNets(); brd.BeginModify(); foreach (IPCB_Primitive item in PR.selectedSourceObjects.arcObjects) { temp = item.Replicate(); brd.AddPCBObject(temp); temp.BeginModify(); temp.MoveByXY(OffsetX, OffsetY); if (temp.GetState_Net() != null) { if (NetCompare.ContainsKey(temp.GetState_Net().GetState_Name())) { if (PR.BoardNets.ContainsKey(NetCompare[temp.GetState_Net().GetState_Name()])) { temp.SetState_Net(PR.BoardNets[NetCompare[temp.GetState_Net().GetState_Name()]]); } } else { //temp.SetState_Net(PCBServer.PCBObjectFactory(TObjectId.eNetObject, TDimensionKind.eNoDimension, TObjectCreationMode.eCreate_Default) as IPCB_Net); temp.SetState_Net(null); } } temp.EndModify(); NewPlacement.arcObjects.Add(temp as IPCB_Arc); } foreach (IPCB_Primitive item in PR.selectedSourceObjects.padObjects) { temp = item.Replicate(); brd.AddPCBObject(temp); temp.BeginModify(); temp.MoveByXY(OffsetX, OffsetY); if (temp.GetState_Net() != null) { if (NetCompare.ContainsKey(temp.GetState_Net().GetState_Name())) { if (PR.BoardNets.ContainsKey(NetCompare[temp.GetState_Net().GetState_Name()])) { temp.SetState_Net(PR.BoardNets[NetCompare[temp.GetState_Net().GetState_Name()]]); } else { temp.SetState_Net(null); } } else { temp.SetState_Net(null); } } temp.EndModify(); NewPlacement.padObjects.Add(temp as IPCB_Pad); } foreach (IPCB_Primitive item in PR.selectedSourceObjects.ViaObjects) { temp = item.Replicate(); brd.AddPCBObject(temp); temp.BeginModify(); temp.MoveByXY(OffsetX, OffsetY); if (temp.GetState_Net() != null) { if (NetCompare.ContainsKey(temp.GetState_Net().GetState_Name())) { if (PR.BoardNets.ContainsKey(NetCompare[temp.GetState_Net().GetState_Name()])) { temp.SetState_Net(PR.BoardNets[NetCompare[temp.GetState_Net().GetState_Name()]]); } else { temp.SetState_Net(null); } } else { temp.SetState_Net(null); } } temp.EndModify(); NewPlacement.ViaObjects.Add(temp as IPCB_Via); } foreach (IPCB_Primitive item in PR.selectedSourceObjects.trackObjects) { temp = item.Replicate(); brd.AddPCBObject(temp); temp.BeginModify(); temp.MoveByXY(OffsetX, OffsetY); if (temp.GetState_Net() != null) { if (NetCompare.ContainsKey(temp.GetState_Net().GetState_Name())) { if (PR.BoardNets.ContainsKey(NetCompare[temp.GetState_Net().GetState_Name()])) { temp.SetState_Net(PR.BoardNets[NetCompare[temp.GetState_Net().GetState_Name()]]); } else { temp.SetState_Net(null); } } else { temp.SetState_Net(null); } } temp.EndModify(); NewPlacement.trackObjects.Add(temp as IPCB_Track); } foreach (IPCB_Primitive item in PR.selectedSourceObjects.textObjects) { temp = item.Replicate(); brd.AddPCBObject(temp); temp.BeginModify(); temp.MoveByXY(OffsetX, OffsetY); if (temp.GetState_Net() != null) { if (NetCompare.ContainsKey(temp.GetState_Net().GetState_Name())) { if (PR.BoardNets.ContainsKey(NetCompare[temp.GetState_Net().GetState_Name()])) { temp.SetState_Net(PR.BoardNets[NetCompare[temp.GetState_Net().GetState_Name()]]); } else { temp.SetState_Net(null); } } else { temp.SetState_Net(null); } } temp.EndModify(); NewPlacement.textObjects.Add(temp as IPCB_Text); } foreach (IPCB_Primitive item in PR.selectedSourceObjects.fillObjects) { temp = item.Replicate(); brd.AddPCBObject(temp); temp.BeginModify(); temp.MoveByXY(OffsetX, OffsetY); if (temp.GetState_Net() != null) { if (NetCompare.ContainsKey(temp.GetState_Net().GetState_Name())) { if (PR.BoardNets.ContainsKey(NetCompare[temp.GetState_Net().GetState_Name()])) { temp.SetState_Net(PR.BoardNets[NetCompare[temp.GetState_Net().GetState_Name()]]); } else { temp.SetState_Net(null); } } else { temp.SetState_Net(null); } } temp.EndModify(); NewPlacement.fillObjects.Add(temp as IPCB_Fill); } foreach (IPCB_Primitive item in PR.selectedSourceObjects.polygonObjects) { temp = item.Replicate(); brd.AddPCBObject(temp); temp.BeginModify(); temp.MoveByXY(OffsetX, OffsetY); if (temp.GetState_Net() != null) { if (NetCompare.ContainsKey(temp.GetState_Net().GetState_Name())) { if (PR.BoardNets.ContainsKey(NetCompare[temp.GetState_Net().GetState_Name()])) { temp.SetState_Net(PR.BoardNets[NetCompare[temp.GetState_Net().GetState_Name()]]); } else { temp.SetState_Net(null); } } else { temp.SetState_Net(null); } } temp.EndModify(); NewPlacement.polygonObjects.Add(temp as IPCB_Polygon); } foreach (IPCB_Primitive item in PR.selectedSourceObjects.primitiveObjects) { temp = item.Replicate(); brd.AddPCBObject(temp); temp.BeginModify(); temp.MoveByXY(OffsetX, OffsetY); if (temp.GetState_Net() != null) { if (NetCompare.ContainsKey(temp.GetState_Net().GetState_Name())) { if (PR.BoardNets.ContainsKey(NetCompare[temp.GetState_Net().GetState_Name()])) { temp.SetState_Net(PR.BoardNets[NetCompare[temp.GetState_Net().GetState_Name()]]); } else { temp.SetState_Net(null); } } else { temp.SetState_Net(null); } } temp.EndModify(); NewPlacement.primitiveObjects.Add(temp); } foreach (IPCB_Primitive item in PR.selectedSourceObjects.regionObjects) { temp = item.Replicate(); brd.AddPCBObject(temp); temp.BeginModify(); temp.MoveByXY(OffsetX, OffsetY); if (temp.GetState_Net() != null) { if (NetCompare.ContainsKey(temp.GetState_Net().GetState_Name())) { if (PR.BoardNets.ContainsKey(NetCompare[temp.GetState_Net().GetState_Name()])) { temp.SetState_Net(PR.BoardNets[NetCompare[temp.GetState_Net().GetState_Name()]]); } else { temp.SetState_Net(null); } } else { temp.SetState_Net(null); } } temp.EndModify(); NewPlacement.regionObjects.Add(temp as IPCB_Region); } string srcRef, dstRef; IPCB_Component srcComp, dstComp; foreach (string item in lstMatched.Items) { srcRef = item.Split('>')[0]; dstRef = item.Split('>')[1]; srcComp = PR.selectedSourceObjects.GetComponent(srcRef); dstComp = PR.selectedDestinationObjects.GetComponent(dstRef); dstComp.BeginModify(); if (srcComp.GetState_Layer() != dstComp.GetState_Layer()) { dstComp.FlipComponent(); } dstComp.SetState_Rotation(srcComp.GetState_Rotation()); dstComp.MoveToXY(OffsetX + srcComp.GetState_XLocation(), OffsetY + srcComp.GetState_YLocation()); //dstComp.Rebuild(); dstComp.EndModify(); } brd.EndModify(); PCBServer.PostProcess(); brd.GraphicallyInvalidate(); //brd.Update_PCBGraphicalView(true, true); //DXP.Utils.RunCommand("PCB:Zoom", "Action=Redraw"); //string process = "PCB:MoveObject"; //string parameters = "Object= Selection"; //DXP.Utils.RunCommand(process, parameters); RemoveMatched("Placed"); } catch (Exception ex) { ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex); return; } }
public void PlaceLayerStackTable() { PCBServer = PCB.GlobalVars.PCBServer; List <IPCB_Primitive> lstLayerStackPrims = new List <IPCB_Primitive>(); //DXP.Utils.RunCommand("PCB:ManageLayerSets", "SetIndex=0"); IPCB_Board pcbBoard = Util.GetCurrentPCB(); if (pcbBoard == null) { return; } if (!pcbBoard.ChooseLocation(ref OffsetX, ref OffsetY, "Select placement location")) { return; } IPCB_MasterLayerStack LStack = pcbBoard.GetState_MasterStack(); //IPCB_Text test = pcbBoard.SelectedObjectsCount ActiveLayer = TV6_Layer.eV6_DrillDrawing; IPCB_LayerObject tmp; tmp = LStack.First(TLayerClassID.eLayerClass_Electrical); do { Layers.Add(tmp as IPCB_ElectricalLayer); //GetState_CopperThickness //GetState_LayerName tmp = LStack.Next(TLayerClassID.eLayerClass_Electrical, tmp); } while (tmp != null); // [Page Number, Layer Num, Ext, Name, POS/NEG, Weight] List <TableData> TableText = new List <TableData>(); string CopperWeight; TableText.Add(new TableData(new string[6] { "1", null, "GD1", "FABRICATION DRAWING", "POS", null }, TV6_Layer.eV6_DrillDrawing)); TableText.Add(new TableData(new string[6] { "2", null, "GTO", "Top Overlay", "POS", null }, TV6_Layer.eV6_TopOverlay)); TableText.Add(new TableData(new string[6] { "3", null, "GTS", "Top Solder", "NEG", null }, TV6_Layer.eV6_TopSolder)); int i = 4; int Sig = 1, Plane = 1; string Ext; foreach (IPCB_ElectricalLayer item in Layers) { System.Diagnostics.Debug.WriteLine(item.GetState_CopperThickness()); System.Diagnostics.Debug.WriteLine(item.GetState_LayerDisplayName(0)); System.Diagnostics.Debug.WriteLine(item.GetState_LayerDisplayName(1)); System.Diagnostics.Debug.WriteLine(item.GetState_LayerDisplayName(2)); //14000 //7000 switch (item.GetState_CopperThickness()) { case 7090: CopperWeight = ".5 oz"; break; case 7000: CopperWeight = ".5 oz"; break; case 7087: CopperWeight = ".5 oz"; break; case 13780: CopperWeight = "1 oz"; break; case 14000: CopperWeight = "1 oz"; break; case 13779: CopperWeight = "1 oz"; break; case 28000: CopperWeight = "2 oz"; break; case 27560: CopperWeight = "2 oz"; break; default: CopperWeight = EDP.Utils.CoordToMils(item.GetState_CopperThickness()).ToString() + "mils"; break; } if (item.GetState_LayerDisplayName(0).Contains("P")) { Ext = "GP" + Plane.ToString(); Plane++; } else if (item.GetState_LayerDisplayName(0).Contains("T")) { Ext = "G" + item.GetState_LayerDisplayName(0); } else if (item.GetState_LayerDisplayName(0).Contains("B")) { Ext = "G" + item.GetState_LayerDisplayName(0); } else { Ext = "G" + Sig.ToString(); Sig++; } //TV6_Layer tempLayer = (TV6_Layer)item; TableText.Add(new TableData(new string[6] { i.ToString(), (i - 3).ToString(), Ext, item.GetState_LayerName(), item.GetState_LayerDisplayName(0).Contains("P") ?"NEG":"POS", CopperWeight }, item.V6_LayerID())); i++; } TableText.Add(new TableData(new string[6] { (LStack.Count_1(3) + 4).ToString(), null, "GBS", "Bottom Solder", "NEG", null }, TV6_Layer.eV6_BottomSolder)); TableText.Add(new TableData(new string[6] { (LStack.Count_1(3) + 5).ToString(), null, "GBO", "Bottom Overlay", "POS", null }, TV6_Layer.eV6_BottomOverlay)); TableText.Add(new TableData(new string[6] { "", null, "TXT", "NC DRILL FILE", null, null }, TV6_Layer.eV6_DrillDrawing)); double pos = -815; foreach (TableData item in TableText) {// [Page Number, Layer Num, Ext, Name, POS/NEG, Weight] if (item.Text[0] != "") { lstLayerStackPrims.Add(CreateString(161, pos, item.Text[0], ActiveLayer)); //Page Number } if (item.Text[1] != "") { lstLayerStackPrims.Add(CreateString(661, pos, item.Text[1], ActiveLayer)); //Layer Num } if (item.Text[2] != "") { lstLayerStackPrims.Add(CreateString(1061, pos, item.Text[2], ActiveLayer)); //Ext } if (item.Text[3] != "") { lstLayerStackPrims.Add(CreateString(1516, pos, item.Text[3], ActiveLayer)); //Name } if (item.Text[4] != "") { lstLayerStackPrims.Add(CreateString(3361, pos, item.Text[4], ActiveLayer)); //POS/NEG } if (item.Text[5] != "") { lstLayerStackPrims.Add(CreateString(3861, pos, item.Text[5], ActiveLayer)); //Weight } if (item.Text[0] != "1") { if (item.Text[0] != "") { lstLayerStackPrims.Add(CreateString(4485, pos, ".Layer_Name", item.CurrentLayer)); //Layer name } if (item.Text[0] != "") { lstLayerStackPrims.Add(CreateString(5985, pos, item.Text[0], item.CurrentLayer)); //Page Number } } pos -= 200; } tmp = LStack.First(TLayerClassID.eLayerClass_Dielectric); double thickness; pos = -1515; do { System.Diagnostics.Debug.WriteLine((tmp as IPCB_DielectricLayer).GetState_DielectricType()); if ((tmp as IPCB_DielectricLayer).GetState_DielectricType() != TDielectricType.eSurfaceMaterial) { thickness = EDP.Utils.CoordToMils((tmp as IPCB_DielectricLayer).GetState_DielectricHeight()) / 1000; thickness = Math.Round(thickness, 4); lstLayerStackPrims.Add(CreateString(-737, pos, thickness.ToString() + "\"", ActiveLayer)); lstLayerStackPrims.Add(CreateTrack(-238, pos + 50, -50, pos + 50, ActiveLayer)); pos -= 200; } tmp = LStack.Next(TLayerClassID.eLayerClass_Dielectric, tmp); } while (tmp != null); PCBServer.PreProcess(); lstLayerStackPrims.AddRange(CreateTemplate(LStack.Count_1(3))); //tmpPrim = PCBServer.PCBObjectFactory(TObjectId.eTrackObject, TDimensionKind.eNoDimension, TObjectCreationMode.eCreate_Default); //if (tmpPrim == null) // return; //IPCB_Track track = tmpPrim as IPCB_Track; foreach (IPCB_Primitive prim in lstLayerStackPrims) { if (prim != null) { pcbBoard.AddPCBObject(prim); } } PCBServer.PostProcess(); }
/// <summary> /// Hides refdes' before running ODB++ outputs /// </summary> /// <returns>True/False if successful.</returns> bool PreODB() { try { IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace; IDXPProject CurrentProject; IDXPDocument PCBDoc = null; CurrentProject = CurrentWorkspace.DM_FocusedProject(); IClient tmpClient = DXP.GlobalVars.Client; IServerDocument PCBServerDoc; //Get pcb doc. for (int i = 0; i < CurrentProject.DM_LogicalDocumentCount(); i++) { if (CurrentProject.DM_LogicalDocuments(i).DM_DocumentKind() == "PCB") { PCBDoc = CurrentProject.DM_LogicalDocuments(i); break; } } if (PCBDoc == null) { MessageBox.Show("Unable to get PCB."); return(false); } PCBServerDoc = tmpClient.GetDocumentByPath(PCBDoc.DM_FullPath()); if (PCBServerDoc == null) //PCB not already open. { PCBServerDoc = tmpClient.OpenDocument("PCB", PCBDoc.DM_FullPath()); ODBFiles.WasOpen = false; } tmpClient.ShowDocument(PCBServerDoc); IPCB_Board Board; if (PCBServer == null) { return(false); } //Get board from pcb doc. Board = PCBServer.GetPCBBoardByPath(PCBDoc.DM_FullPath()); //Get current board if (Board == null) { return(false); } //Prep ODB class. ODBFiles.Board = Board; ODBFiles.PCBServerDoc = PCBServerDoc; PCBServer.PreProcess(); //Hid refdes if enables in preferences. if (ToolsPreferences.ODB_HideRefDes) { new ShowHideRefDes().ShowHide(Board, false); } PCBServer.PostProcess(); Board.ViewManager_FullUpdate(); return(true); } catch (Exception ex) { ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex); return(false); } }