private void GetXYPlane(Part component, out DatumPlane XYPlane) { DatumCollection datums = component.Datums; object[] datums1 = component.Datums.ToArray(); List <DatumPlane> datumPlanes = new List <DatumPlane>(); XYPlane = null; foreach (object obj in datums1) { DatumPlane plane = obj as DatumPlane; if (plane != null) { datumPlanes.Add(plane); } } foreach (DatumPlane plane in datumPlanes) { if (plane.Normal.Z == 1) { XYPlane = plane; } } }
public void ConstraintCreate() { System.IO.StreamWriter SW = new System.IO.StreamWriter("D:\\GIT\\AUTO_BOLTS_PLACE\\NXDebugLog.log"); Component Comp = Assembly.ComponentAssembly.RootComponent; //now what does NX tags do? Need to know. //how to make use of tags to obtain the parts //https://community.plm.automation.siemens.com/t5/NX-Programming-Customization-Forum/Creating-Assesbly-Constraint-using-NXopen/td-p/476978 NXOpen.Layer.StateInfo[] stateArray1 = new NXOpen.Layer.StateInfo[1]; stateArray1[0] = new NXOpen.Layer.StateInfo(32, NXOpen.Layer.State.Selectable); Assembly.Layers.ChangeStates(stateArray1, false); foreach (Component C in Comp.GetChildren()) { string name = C.Name; Part owningpart = (NXOpen.Part)C.OwningPart; owningpart.LoadFully(); DatumCollection dc = owningpart.Datums; try { foreach (DatumPlane d in dc) { string nam2 = d.Feature.Name; string nam3 = d.Layer.ToString(); SW.WriteLine(nam3); //string nam3 = d. } } catch (Exception E3) { } } SW.Close(); }