public void ModelTest() { IPCB_ServerInterface PCBServer = PCB.GlobalVars.PCBServer; IPCB_ComponentBody STEPmodel = (IPCB_ComponentBody)PCBServer.PCBObjectFactory(PCB.TObjectId.eComponentBodyObject, TDimensionKind.eNoDimension, PCB.TObjectCreationMode.eCreate_Default); IPCB_Model Model = STEPmodel.ModelFactory_FromFilename("C:\\test.step", false); STEPmodel.SetState_FromModel(); Model.SetState(90, 100, 110, 12000); double RotX; double RotY; double RotZ; int StandOff; Model.GetState(out RotX, out RotY, out RotZ, out StandOff); //here occurs the error!!! STEPmodel.SetModel(Model); IPCB_Component Component = null; Component.AddPCBObject(STEPmodel); ////This code produces the same error: //CIter:= Component.GroupIterator_Create; // CIter.AddFilter_ObjectSet(MkSet(eComponentBodyObject)); //STEPmodel:= CIter.FirstPCBObject; // While(STEPmodel <> nil) do // begin // StepModel.GetModel.GetState(RotX, RotY, RotZ, StandOff); //here occurs the error!!! //STEPmodel:= CIter.NextPCBObject; // end; }
/// <summary> /// Gets the total height of a body. /// </summary> /// <param name="Body">Body to adjust</param> /// <returns>Height of body in AD coords</returns> int GetCompHeight(IPCB_ComponentBody Body) { double RotX, RotY, RotZ; int StandOff; if (Body.GetState_DescriptorString().Contains("STEP")) { Body.GetModel().GetState(out RotX, out RotY, out RotZ, out StandOff); Body.SaveModelToFile("C:\\test.step"); return(Body.GetOverallHeight()); } else { return(Body.GetOverallHeight()); } }
/// <summary> /// Sets the body height to the new value supplied. /// </summary> /// <param name="Body">Body to adjust</param> /// <param name="value">Desired height in AD coords</param> void SetCompHeight(IPCB_ComponentBody Body, int value) { double RotX, RotY, RotZ; int StandOff; Body.BeginModify(); if (Body.GetState_DescriptorString().Contains("STEP")) { //todo: alter offset dont override Body.GetModel().GetState(out RotX, out RotY, out RotZ, out StandOff); Body.GetModel().SetState(RotX, RotY, RotZ, StandOff + value - Body.GetOverallHeight()); //todo: value = coord or mils? } else { Body.SetOverallHeight(value); } Body.EndModify(); }
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); }