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); }
IPCB_Primitive CreateTrack(double x1, double y1, double x2, double y2, TV6_Layer Layer) { IPCB_Primitive tmpPrim = PCBServer.PCBObjectFactory(TObjectId.eTrackObject, TDimensionKind.eNoDimension, TObjectCreationMode.eCreate_Default); IPCB_Track track = tmpPrim as IPCB_Track; track.SetState_X1(OffsetX + EDP.Utils.MilsToCoord(x1 - 4285)); track.SetState_Y1(OffsetY + EDP.Utils.MilsToCoord(y1)); track.SetState_X2(OffsetX + EDP.Utils.MilsToCoord(x2 - 4285)); track.SetState_Y2(OffsetY + EDP.Utils.MilsToCoord(y2)); track.SetState_Layer(Layer); track.SetState_Width(EDP.Utils.MilsToCoord(20)); return(tmpPrim); }
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); }