public void GetDestinationParts() { SelectedDestRef = new List <string>(); selectedDestinationObjects = new clsSelectedObjects(); Destination = new clsOutput(); string parameterName, parameterValue; IPCB_BoardIterator BoardIterator; IPCB_Parameter parameter; IPCB_Primitive Primitive; IPCB_Board Board = Util.GetCurrentPCB(); if (Board == null) { return; } //Iterate theough all components on the board. BoardIterator = Board.BoardIterator_Create(); PCB.TObjectSet FilterSet = new PCB.TObjectSet(); BoardIterator.AddFilter_ObjectSet(Util.PCBAllObject); BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers. BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll); Primitive = BoardIterator.FirstPCBObject(); while (Primitive != null) { if (Primitive.GetState_Selected()) { switch (Primitive.GetState_ObjectID()) { case TObjectId.eComponentObject: IPCB_Component componentObject = Primitive as IPCB_Component; selectedDestinationObjects.componentObjects.Add(componentObject); clsOutput.st_IPCB_Component newComp = new clsOutput.st_IPCB_Component(); IPCB_GroupIterator compIterator = componentObject.GroupIterator_Create(); PCB.TObjectSet compFilterset = new PCB.TObjectSet(); compFilterset.Add(TObjectId.ePadObject); compIterator.AddFilter_ObjectSet(compFilterset); compIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers. IPCB_Pad pad = compIterator.FirstPCBObject() as IPCB_Pad; int pinCount = 0; newComp.Nets = new SerializableDictionary <string, string>(); while (pad != null) { if (pad.GetState_Net() != null) { if (!newComp.Nets.ContainsKey(pad.GetState_Name())) { newComp.Nets.Add(pad.GetState_Name(), pad.GetState_Net().GetState_Name()); } } pinCount++; pad = compIterator.NextPCBObject() as IPCB_Pad; } componentObject.GroupIterator_Destroy(ref compIterator); IPCB_PrimitiveParameters componentParameters = componentObject as IPCB_PrimitiveParameters; newComp.Parameters = new SerializableDictionary <string, string>(); for (int i = 0; i < componentParameters.Count(); i++) { parameter = componentParameters.GetParameterByIndex(i); parameterName = parameter.GetName(); if (parameter.GetValue() == null) { parameterValue = "null"; } else { parameterValue = parameter.GetValue(); } newComp.Parameters.Add(parameterName, parameterValue); } newComp.RefDes = componentObject.GetState_Name().GetState_Text(); newComp.Footprint = componentObject.GetState_Pattern(); newComp.PinCount = pinCount; Destination.Components.Add(newComp.RefDes, newComp); SelectedDestRef.Add(newComp.RefDes); //?componentObject.GetState_DescriptorString() //"SOIC Component U5FM-QT#94L9#-20.000MHz (5528.098mil,6358.425mil) on Top Layer" //? componentObject.GetState_DetailString() //"Component U5FM Comment:QT#94L9#-20.000MHz Footprint: QT194" //?componentObject.GetState_Layer() //componentObject.GetState_Pattern() Footprint //componentObject.GetState_SourceDesignator() Refdes //componentObject.GetState_SourceFootprintLibrary() library //componentObject.GetState_SourceLibReference() corp number //componentObject.GetState_XLocation() //componentObject.GetState_YLocation() System.Diagnostics.Debug.WriteLine(componentObject.GetState_DescriptorString()); break; default: //selectedSourceObjects.primitiveObjects.Add(Primitive); System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); break; } //Primitive.Export_ToParameters(ref RefDes); } Primitive = BoardIterator.NextPCBObject(); } //Iterator clean-up Board.BoardIterator_Destroy(ref BoardIterator); //clsOutput outputb; //outputb = new clsOutput(); //XmlSerialization.WriteToXmlFile<clsOutput>(@"S:\Dropbox\Altium Extensions\test.xml", Output); //outputb = XmlSerialization.ReadFromXmlFile<clsOutput>(@"S:\Dropbox\Altium Extensions\test.xml"); //@"S:\Dropbox\Altium Extensions\test.xml" //"C:\\Users\\rlyne\\Dropbox\\Altium Extensions\\SwRI_Tools\\bin\\test.xml" }
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 GetInitialParts() { try { SelectedSourceRef = new List <string>(); selectedSourceObjects = new clsSelectedObjects(); Source = new clsOutput(); IPCB_BoardIterator BoardIterator; IPCB_Primitive Primitive; IPCB_Board Board = Util.GetCurrentPCB(); if (Board == null) { return; } //Iterate theough all components on the board. BoardIterator = Board.BoardIterator_Create(); PCB.TObjectSet FilterSet = new PCB.TObjectSet(); BoardIterator.AddFilter_ObjectSet(Util.PCBAllObject); BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers. BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll); Primitive = BoardIterator.FirstPCBObject(); while (Primitive != null) { if (Primitive.GetState_Selected()) { switch (Primitive.GetState_ObjectID()) { case TObjectId.eArcObject: IPCB_Arc arcObject = Primitive as IPCB_Arc; selectedSourceObjects.arcObjects.Add(arcObject); clsOutput.st_IPCB_Arc newArc = new clsOutput.st_IPCB_Arc(); newArc.StartX = arcObject.GetState_StartX(); newArc.StartY = arcObject.GetState_StartY(); newArc.EndX = arcObject.GetState_EndX(); newArc.EndY = arcObject.GetState_EndY(); newArc.StartAngle = arcObject.GetState_StartAngle(); newArc.EndAngle = arcObject.GetState_EndAngle(); newArc.CenterX = arcObject.GetState_CenterX(); newArc.CenterY = arcObject.GetState_CenterY(); newArc.KeepOut = arcObject.GetState_IsKeepout(); newArc.LineWidth = arcObject.GetState_LineWidth(); if (arcObject.GetState_Net() != null) { newArc.Net = arcObject.GetState_Net().GetState_Name(); } else { newArc.Net = null; } newArc.PasteMaskExpansion = arcObject.GetState_PasteMaskExpansion(); newArc.Radius = arcObject.GetState_Radius(); newArc.SolderMaskExpansion = arcObject.GetState_SolderMaskExpansion(); newArc.Layer = Util.GetLayerName(arcObject.GetState_Board(), arcObject.GetState_V7Layer()); Source.Arcs.Add(newArc); System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); break; case TObjectId.ePadObject: IPCB_Pad padObject = Primitive as IPCB_Pad; selectedSourceObjects.padObjects.Add(padObject); System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); break; case TObjectId.eViaObject: System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); IPCB_Via ViaObject = Primitive as IPCB_Via; clsOutput.st_IPCB_Via newVia = new clsOutput.st_IPCB_Via(); string test = ""; ViaObject.Export_ToParameters(ref test); newVia.HoleSize = ViaObject.GetState_HoleSize(); newVia.IsTestPoint_Bottom = ViaObject.GetState_IsTestPoint_Bottom(); newVia.IsTestPoint_Top = ViaObject.GetState_IsTestPoint_Top(); newVia.IsTenting = ViaObject.GetState_IsTenting(); newVia.IsTenting_Bottom = ViaObject.GetState_IsTenting_Bottom(); newVia.IsTenting_Top = ViaObject.GetState_IsTenting_Top(); //ViaObject.GetState_Layer(); ViaObject.GetState_V7Layer(); newVia.Net = ViaObject.GetState_Net().GetState_Name(); newVia.Size = ViaObject.GetState_Size(); newVia.SolderMaskExpansion = ViaObject.GetState_SolderMaskExpansion(); newVia.HighLayer = Util.GetLayerName(ViaObject.GetState_Board(), ViaObject.GetState_HighLayer()); newVia.LowLayer = Util.GetLayerName(ViaObject.GetState_Board(), ViaObject.GetState_LowLayer()); newVia.TearDrop = ViaObject.GetState_TearDrop(); newVia.XLocation = ViaObject.GetState_XLocation(); newVia.YLocation = ViaObject.GetState_YLocation(); Source.Vias.Add(newVia); selectedSourceObjects.ViaObjects.Add(ViaObject); break; case TObjectId.eTrackObject: IPCB_Track trackObject = Primitive as IPCB_Track; System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); selectedSourceObjects.trackObjects.Add(trackObject); clsOutput.st_IPCB_Track newTrack = new clsOutput.st_IPCB_Track(); newTrack.X1 = trackObject.GetState_X1(); newTrack.X2 = trackObject.GetState_X2(); newTrack.Y1 = trackObject.GetState_Y1(); newTrack.Y2 = trackObject.GetState_Y2(); newTrack.Width = trackObject.GetState_Width(); newTrack.Layer = Util.GetLayerName(trackObject.GetState_Board(), trackObject.GetState_V7Layer()); if (trackObject.GetState_Net() == null) { newTrack.Net = null; } else { newTrack.Net = trackObject.GetState_Net().GetState_Name(); } newTrack.Keepout = trackObject.GetState_IsKeepout(); Source.Tracks.Add(newTrack); break; case TObjectId.eTextObject: IPCB_Text textObject = Primitive as IPCB_Text; selectedSourceObjects.textObjects.Add(textObject); System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); break; case TObjectId.eFillObject: IPCB_Fill fillObject = Primitive as IPCB_Fill; selectedSourceObjects.fillObjects.Add(fillObject); clsOutput.st_IPCB_Fill newFill = new clsOutput.st_IPCB_Fill(); newFill.Length = fillObject.GetState_Length(); newFill.LocationX = fillObject.GetState_LocationX(); newFill.LocationY = fillObject.GetState_LocationY(); if (fillObject.GetState_Net() != null) { newFill.Net = fillObject.GetState_Net().GetState_Name(); } newFill.PasteMaskExpansion = fillObject.GetState_PasteMaskExpansion(); if (fillObject.GetState_Polygon() != null) { MessageBox.Show("Polygon error. Please fix."); } //fillObject.GetState_Polygon(); //convert to something newFill.Rotation = fillObject.GetState_Rotation(); newFill.SolderMaskExpansion = fillObject.GetState_SolderMaskExpansion(); newFill.Layer = Util.GetLayerName(fillObject.GetState_Board(), fillObject.GetState_V7Layer()); newFill.Width = fillObject.GetState_Width(); newFill.X1Location = fillObject.GetState_X1Location(); newFill.X2Location = fillObject.GetState_X2Location(); newFill.XLocation = fillObject.GetState_XLocation(); newFill.Y1Location = fillObject.GetState_Y1Location(); newFill.Y2Location = fillObject.GetState_Y2Location(); newFill.YLocation = fillObject.GetState_YLocation(); newFill.Keepout = fillObject.GetState_IsKeepout(); Source.Fills.Add(newFill); System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); break; //case TObjectId.eConnectionObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eNetObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; case TObjectId.eComponentObject: IPCB_Component componentObject = Primitive as IPCB_Component; selectedSourceObjects.componentObjects.Add(componentObject); clsOutput.st_IPCB_Component newComp = new clsOutput.st_IPCB_Component(); IPCB_GroupIterator compIterator = componentObject.GroupIterator_Create(); PCB.TObjectSet compFilterset = new PCB.TObjectSet(); compFilterset.Add(TObjectId.ePadObject); compIterator.AddFilter_ObjectSet(compFilterset); compIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers. IPCB_Pad pad = compIterator.FirstPCBObject() as IPCB_Pad; int pinCount = 0; newComp.Nets = new SerializableDictionary <string, string>(); while (pad != null) { if (pad.GetState_Net() != null) { if (!newComp.Nets.ContainsKey(pad.GetState_Name())) { newComp.Nets.Add(pad.GetState_Name(), pad.GetState_Net().GetState_Name()); } } pinCount++; pad = compIterator.NextPCBObject() as IPCB_Pad; } componentObject.GroupIterator_Destroy(ref compIterator); newComp.Parameters = new SerializableDictionary <string, string>(); IPCB_PrimitiveParameters componentParameters = componentObject as IPCB_PrimitiveParameters; for (int i = 0; i < componentParameters.Count(); i++) { IPCB_Parameter parameter = componentParameters.GetParameterByIndex(i); newComp.Parameters.Add(parameter.GetName(), parameter.GetValue()); } newComp.RefDes = componentObject.GetState_Name().GetState_Text(); newComp.Footprint = componentObject.GetState_Pattern(); newComp.PinCount = pinCount; Source.Components.Add(newComp.RefDes, newComp); SelectedSourceRef.Add(newComp.RefDes); //?componentObject.GetState_DescriptorString() //"SOIC Component U5FM-QT#94L9#-20.000MHz (5528.098mil,6358.425mil) on Top Layer" //? componentObject.GetState_DetailString() //"Component U5FM Comment:QT#94L9#-20.000MHz Footprint: QT194" //?componentObject.GetState_Layer() //componentObject.GetState_Pattern() Footprint //componentObject.GetState_SourceDesignator() Refdes //componentObject.GetState_SourceFootprintLibrary() library //componentObject.GetState_SourceLibReference() corp number //componentObject.GetState_XLocation() //componentObject.GetState_YLocation() System.Diagnostics.Debug.WriteLine(componentObject.GetState_DescriptorString()); break; case TObjectId.ePolyObject: IPCB_Polygon polygonObject = Primitive as IPCB_Polygon; selectedSourceObjects.polygonObjects.Add(polygonObject); clsOutput.st_IPCB_Polygon newPoly = new clsOutput.st_IPCB_Polygon(); //polygonObject.GetState_BorderWidth(); //polygonObject.GetState_Coordinate(); newPoly.Keepout = polygonObject.GetState_IsKeepout(); newPoly.Layer = Util.GetLayerName(polygonObject.GetState_Board(), polygonObject.GetState_V7Layer()); newPoly.MitreCorners = polygonObject.GetState_MitreCorners(); if (polygonObject.GetState_Net() != null) { newPoly.Net = polygonObject.GetState_Net().GetState_Name(); } newPoly.PasteMaskExpansion = polygonObject.GetState_PasteMaskExpansion(); if (polygonObject.GetState_Polygon() != null) { MessageBox.Show("Polygon error. Please fix."); } newPoly.PolySegments = new List <SPolySegment>(); for (int i = 0; i < polygonObject.GetState_PointCount(); i++) { newPoly.PolySegments.Add(polygonObject.GetState_Segments(i).Data); } newPoly.SolderMaskExpansion = polygonObject.GetState_SolderMaskExpansion(); newPoly.TrackSize = polygonObject.GetState_TrackSize();//??? newPoly.XLocation = polygonObject.GetState_XLocation(); newPoly.YLocation = polygonObject.GetState_YLocation(); newPoly.PolyType = polygonObject.GetState_PolygonType(); Source.Polygons.Add(newPoly); System.Diagnostics.Debug.WriteLine(polygonObject.GetState_DescriptorString()); break; case TObjectId.eRegionObject: IPCB_Region regionObject = Primitive as IPCB_Region; selectedSourceObjects.regionObjects.Add(regionObject); clsOutput.st_IPCB_Region newRegion = new clsOutput.st_IPCB_Region(); if (regionObject.GetHoleCount() > 0) { MessageBox.Show("Region issue"); } newRegion.Keepout = regionObject.GetState_IsKeepout(); newRegion.RegionKind = regionObject.GetState_Kind(); newRegion.Layer = Util.GetLayerName(regionObject.GetState_Board(), regionObject.GetState_V7Layer()); if (regionObject.GetState_Net() != null) { newRegion.Net = regionObject.GetState_Net().GetState_Name(); } newRegion.PasteMaskExpansion = regionObject.GetState_PasteMaskExpansion(); newRegion.SolderMaskExpansion = regionObject.GetState_SolderMaskExpansion(); List <clsOutput.st_Contour> Contours; newRegion.GeometricPolygons = new List <List <clsOutput.st_Contour> >(); for (int i = 0; i < regionObject.GetGeometricPolygon().GetState_Count(); i++) { Contours = new List <clsOutput.st_Contour>(); for (int j = 0; j < regionObject.GetGeometricPolygon().GetState_Contour(i).GetState_Count(); j++) { Contours.Add(new clsOutput.st_Contour() { X = regionObject.GetGeometricPolygon().GetState_Contour(i).GetState_PointX(j), Y = regionObject.GetGeometricPolygon().GetState_Contour(i).GetState_PointY(j) }); } newRegion.GeometricPolygons.Add(Contours); } //?regionObject.GetGeometricPolygon().GetState_Count() //?regionObject.GetGeometricPolygon().GetState_Contour(0) //?regionObject.GetGeometricPolygon().GetState_Contour(0).GetState_Count() //?regionObject.GetGeometricPolygon().GetState_Contour(0).GetState_PointY(0) //?regionObject.GetGeometricPolygon().GetState_Contour(0).GetState_PointX(0) Source.Regions.Add(newRegion); System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); break; //case TObjectId.eComponentBodyObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eDimensionObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eCoordinateObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eClassObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eRuleObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eFromToObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eDifferentialPairObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eViolationObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eEmbeddedObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eEmbeddedBoardObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eSplitPlaneObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eTraceObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eSpareViaObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eBoardObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; //case TObjectId.eBoardOutlineObject: // System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); // break; default: selectedSourceObjects.primitiveObjects.Add(Primitive); System.Diagnostics.Debug.WriteLine(Primitive.GetState_DescriptorString()); break; } //Primitive.Export_ToParameters(ref RefDes); } Primitive = BoardIterator.NextPCBObject(); } //Iterator clean-up Board.BoardIterator_Destroy(ref BoardIterator); //clsOutput outputb; //outputb = new clsOutput(); //XmlSerialization.WriteToXmlFile<clsOutput>(@"S:\Dropbox\Altium Extensions\test.xml", Output); //outputb = XmlSerialization.ReadFromXmlFile<clsOutput>(@"S:\Dropbox\Altium Extensions\test.xml"); //@"S:\Dropbox\Altium Extensions\test.xml" //"C:\\Users\\rlyne\\Dropbox\\Altium Extensions\\SwRI_Tools\\bin\\test.xml" } catch (Exception ex) { ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex); return; } }