Example #1
0
 internal Cone(NXOpen.Face nxopenFace) : base(nxopenFace)
 {
     if (nxopenFace.SolidFaceType != NXOpen.Face.FaceType.Conical)
     {
         throw new ArgumentException("Input object must be of type NXOpen.Face.FaceType.Conical");
     }
     base.NXOpenTaggedObject = nxopenFace;
 }
Example #2
0
 internal Bsurface(NXOpen.Face nxopenFace) : base(nxopenFace)
 {
     if (nxopenFace.SolidFaceType != NXOpen.Face.FaceType.Parametric)
     {
         throw new ArgumentException("Input object must be of type NXOpen.Face.FaceType.Parametric");
     }
     base.NXOpenTaggedObject = nxopenFace;
 }
Example #3
0
 internal Blend(NXOpen.Face nxopenFace) : base(nxopenFace)
 {
     if (nxopenFace.SolidFaceType != NXOpen.Face.FaceType.Blending)
     {
         throw new ArgumentException("Input object must be of type NXOpen.Face.FaceType.Blending");
     }
     base.NXOpenTaggedObject = nxopenFace;
 }
Example #4
0
 public static Snap.NX.Face Wrap(Tag nxopenFaceTag)
 {
     if (nxopenFaceTag == Tag.Null)
     {
         return(null);
     }
     if (Snap.NX.NXObject.GetTypeFromTag(nxopenFaceTag) != ObjectTypes.Type.Face)
     {
         throw new ArgumentException("Input tag doesn't belong to an NXOpen.Face object");
     }
     NXOpen.Face nxopenFace = (NXOpen.Face)NXObjectManager.Get(nxopenFaceTag);
     return(CreateFace(nxopenFace));
 }
Example #5
0
 internal static Snap.NX.OffsetFace CreateOffsetFace(Snap.NX.Face[] faces, Snap.Number distance, bool direction)
 {
     NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
     NXOpen.Features.OffsetFaceBuilder featureBuilder = workPart.Features.CreateOffsetFaceBuilder(null);
     featureBuilder.Distance.RightHandSide = distance.ToString();
     SelectionIntentRule[] rules = new SelectionIntentRule[faces.Length];
     for (int i = 0; i < faces.Length; i++)
     {
         NXOpen.Face[] boundaryFaces = new NXOpen.Face[0];
         rules[i] = workPart.ScRuleFactory.CreateRuleFaceTangent((NXOpen.Face)faces[i], boundaryFaces);
     }
     featureBuilder.FaceCollector.ReplaceRules(rules, false);
     featureBuilder.Direction = direction;
     NXOpen.Features.OffsetFace offsetFace = (NXOpen.Features.OffsetFace)Snap.NX.Feature.CommitFeature(featureBuilder);
     featureBuilder.Destroy();
     return(new Snap.NX.OffsetFace(offsetFace));
 }
Example #6
0
        internal static Snap.NX.ExtractFace CreateExtractFace(Snap.NX.Face[] faces)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.ExtractFaceBuilder featureBuilder = workPart.Features.CreateExtractFaceBuilder(null);
            featureBuilder.FaceOption = NXOpen.Features.ExtractFaceBuilder.FaceOptionType.FaceChain;
            NXOpen.Face[] faceArray = new NXOpen.Face[faces.Length];
            for (int i = 0; i < faces.Length; i++)
            {
                faceArray[i] = (NXOpen.Face)faces[i];
            }
            FaceDumbRule rule = workPart.ScRuleFactory.CreateRuleFaceDumb(faceArray);

            SelectionIntentRule[] rules = new SelectionIntentRule[] { rule };
            featureBuilder.FaceChain.ReplaceRules(rules, false);
            NXOpen.Features.ExtractFace extract = (NXOpen.Features.ExtractFace)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            return(new Snap.NX.ExtractFace(extract));
        }
Example #7
0
        internal static Snap.NX.ProjectCurve CreateProjectCurve2(Snap.NX.Curve[] curves, Snap.NX.Point[] points, Snap.NX.Face face)
        {
            NXOpen.Part work = Globals.Session.Parts.Work;
            NXOpen.Features.ProjectCurveBuilder featureBuilder = work.Features.CreateProjectCurveBuilder(null);
            featureBuilder.CurveFitData.Tolerance = Globals.DistanceTolerance;
            featureBuilder.AngleToProjectionVector.RightHandSide = "0";
            featureBuilder.SectionToProject.DistanceTolerance    = Globals.DistanceTolerance;
            featureBuilder.SectionToProject.ChainingTolerance    = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            featureBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.CurvesAndPoints);
            if (curves != null)
            {
                Snap.NX.Section sectionToProject = featureBuilder.SectionToProject;
                for (int i = 0; i < curves.Length; i++)
                {
                    sectionToProject.AddICurve(new Snap.NX.ICurve[] { curves[i] });
                }
            }
            if (points != null)
            {
                NXOpen.Point[] pointArray = new NXOpen.Point[points.Length];
                for (int j = 0; j < pointArray.Length; j++)
                {
                    pointArray[j] = (NXOpen.Point)points[j];
                }
                CurveDumbRule rule = work.ScRuleFactory.CreateRuleCurveDumbFromPoints(pointArray);
                featureBuilder.SectionToProject.AllowSelfIntersection(true);
                SelectionIntentRule[] ruleArray = new SelectionIntentRule[] { rule };
                Point3d helpPoint = new Point3d(0.0, 0.0, 0.0);
                featureBuilder.SectionToProject.AddToSection(ruleArray, null, null, null, helpPoint, NXOpen.Section.Mode.Create, false);
            }
            ScCollector collector = work.ScCollectors.CreateCollector();

            NXOpen.Face[] faces = new NXOpen.Face[] { face };
            FaceDumbRule  rule2 = work.ScRuleFactory.CreateRuleFaceDumb(faces);

            SelectionIntentRule[] rules = new SelectionIntentRule[] { rule2 };
            collector.ReplaceRules(rules, false);
            featureBuilder.FaceToProjectTo.Add(collector);
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.SectionToProject.CleanMappingData();
            featureBuilder.Destroy();
            return((NXOpen.Features.ProjectCurve)feature);
        }
Example #8
0
        internal static Snap.NX.Face CreateFace(NXOpen.Face nxopenFace)
        {
            Snap.NX.Face snapFace = new Snap.NX.Face(nxopenFace);
            switch (GetFaceType(snapFace))
            {
            case ObjectTypes.SubType.FaceBlend:
                return(new Blend(nxopenFace));

            case ObjectTypes.SubType.FaceBsurface:
                return(new Bsurface(nxopenFace));

            case ObjectTypes.SubType.FaceCone:
                return(new Cone(nxopenFace));

            case ObjectTypes.SubType.FaceCylinder:
                return(new Cylinder(nxopenFace));

            case ObjectTypes.SubType.FaceExtruded:
                return(new Extruded(nxopenFace));

            case ObjectTypes.SubType.FaceOffset:
                return(new Offset(nxopenFace));

            case ObjectTypes.SubType.FacePlane:
                return(new Plane(nxopenFace));

            case ObjectTypes.SubType.FaceRevolved:
                return(new Revolved(nxopenFace));

            case ObjectTypes.SubType.FaceSphere:
                return(new Sphere(nxopenFace));

            case ObjectTypes.SubType.FaceTorus:
                return(new Torus(nxopenFace));
            }
            return(snapFace);
        }
Example #9
0
 internal Torus(NXOpen.Face nxopenFace) : base(nxopenFace)
 {
     NXOpen.Face.FaceType solidFaceType = nxopenFace.SolidFaceType;
     base.NXOpenTaggedObject = nxopenFace;
 }
Example #10
0
 protected Face(NXOpen.Face nxopenFace) : base(nxopenFace)
 {
     base.NXOpenTaggedObject = nxopenFace;
 }
Example #11
0
        public void ToNXFile(Session nxSession)
        {
            NXOpen.Part nxSubAssem;
            var         newFile = new NewNXfile();
            var         fileDir = new NewNXfile();

            for (int i = 0; i < compCount; i++)
            {
                nxRootAssem = nxSession.Parts.Work;
                if (compName[i] == "Default SubAssembly")
                {
                    continue;
                }
                NXOpen.FileNew compFile = nxSession.Parts.FileNew();
                newFile.NXfile(compFile, fileDir.subassemdir(compName[i]));
                compFile.MakeDisplayedPart = false;
                NXOpen.Assemblies.CreateNewComponentBuilder createNewComponentBuilder1;
                createNewComponentBuilder1 = nxRootAssem.AssemblyManager.CreateNewComponentBuilder();
                createNewComponentBuilder1.NewComponentName = compName[i];
                createNewComponentBuilder1.ReferenceSet     = NXOpen.Assemblies.CreateNewComponentBuilder.ComponentReferenceSetType.EntirePartOnly;
                createNewComponentBuilder1.ReferenceSetName = "Entire Part";
                createNewComponentBuilder1.NewFile          = compFile;
                NXOpen.NXObject nXObject_SubAssem = createNewComponentBuilder1.Commit();
                createNewComponentBuilder1.Destroy();
                nxSubAssem = (NXOpen.Part)nxSession.Parts.FindObject(compName[i]);
                NXObject[] nxGeom = new NXObject[partCount];
                for (int j = 0; j < partCount; j++)
                {
                    NXOpen.BasePart       basePart1;
                    NXOpen.PartLoadStatus partLoadStatus, partLoadStatus2;
                    basePart1 = nxSession.Parts.OpenBase(fileDir.partdir(partFileName[j]), out partLoadStatus);
                    partLoadStatus.Dispose();
                    basepoint1      = new NXOpen.Point3d(0.0, 0.0, 0.0);
                    orientation1    = new NXOpen.Matrix3x3();
                    orientation1.Xx = 1.0;
                    orientation1.Xy = 0.0;
                    orientation1.Xz = 0.0;
                    orientation1.Yx = 0.0;
                    orientation1.Yy = 1.0;
                    orientation1.Yz = 0.0;
                    orientation1.Zx = 0.0;
                    orientation1.Zy = 0.0;
                    orientation1.Zz = 1.0;
                    NXOpen.Assemblies.Component component1;
                    component1 = nxRootAssem.ComponentAssembly.AddComponent(fileDir.partdir(partFileName[j]), "MODEL", "A1-1", basepoint1, orientation1, -1, out partLoadStatus2, true);
                    partLoadStatus2.Dispose();
                    NXOpen.Assemblies.Component[] origComponents1 = new NXOpen.Assemblies.Component[1];
                    origComponents1[0] = component1;
                    NXOpen.Assemblies.Component   component2 = (NXOpen.Assemblies.Component)nXObject_SubAssem;
                    NXOpen.Assemblies.Component[] newComponents1;
                    NXOpen.ErrorList errorList1;
                    nxSubAssem.ComponentAssembly.RestructureComponents(origComponents1, component2, true, out newComponents1, out errorList1);
                    errorList1.Dispose();
                    nxGeom[i] = origComponents1[0];
                    string reef = nxGeom[i].OwningComponent.DisplayName;
                    Console.WriteLine("*************************" + reef);
                }
                /*Working Information with Hardcoded information;*/
                ComponentPositioner[]         tempcomponentPositioner1 = new ComponentPositioner[2];
                ComponentConstraint[]         tempcomponentConstraint1 = new ComponentConstraint[2];
                ComponentPositioner[]         componentPositioner1     = new ComponentPositioner[2];
                ComponentPositioner[]         componentPositioner2     = new ComponentPositioner[2];
                ComponentConstraint[]         componentConstraint1     = new ComponentConstraint[2];
                ComponentConstraint[]         componentConstraint2     = new ComponentConstraint[2];
                NXOpen.Assemblies.Component[] component01 = new Component[2];
                NXOpen.Assemblies.Component[] component02 = new Component[2];
                for (int m = 0; m < 2; m++)
                {
                    component01[m] = (NXOpen.Assemblies.Component)nxSubAssem.ComponentAssembly.RootComponent.FindObject("COMPONENT " + partname[m] + " 1");
                    //NXOpen.Assemblies.Component component02 = (NXOpen.Assemblies.Component)nxSubAssem.ComponentAssembly.RootComponent.FindObject("COMPONENT " + partname[0] + " 1");
                }

                /*
                 * tempcomponentPositioner1[0] = nxSubAssem.ComponentAssembly.Positioner;
                 * tempcomponentPositioner1[0].BeginAssemblyConstraints();
                 * Constraint tempconstraint1;
                 * tempconstraint1 = tempcomponentPositioner1[0].CreateConstraint(true);
                 * tempcomponentConstraint1[0] = (NXOpen.Positioning.ComponentConstraint)tempconstraint1;
                 * tempcomponentConstraint1[0].ConstraintType = NXOpen.Positioning.Constraint.Type.Concentric;
                 * Edge edge1 = (NXOpen.Edge)component01[0].FindObject(EdgeNames[0]);
                 * ConstraintReference ConsRef1 = tempcomponentConstraint1[0].CreateConstraintReference(component01[0],edge1,false,false,false);
                 * Edge edge2 = (NXOpen.Edge)component01[1].FindObject(EdgeNames[1]);
                 * ConstraintReference ConsRef2 = tempcomponentConstraint1[0].CreateConstraintReference(component01[1], edge2, false, false, false);
                 */


                for (int k = 0; k < 2; k++)
                {
                    if (constNamesTemp[k].Contains("Coaxial"))
                    {
                        componentPositioner1[k] = nxSubAssem.ComponentAssembly.Positioner;
                        componentPositioner1[k].BeginAssemblyConstraints();
                        Constraint constraint1;
                        constraint1             = componentPositioner1[k].CreateConstraint(true);
                        componentConstraint1[k] = (NXOpen.Positioning.ComponentConstraint)constraint1;
                        //componentConstraint1[k].ConstraintAlignment = NXOpen.Positioning.Constraint.Alignment.ContraAlign;
                        componentConstraint1[k].ConstraintType = NXOpen.Positioning.Constraint.Type.Fit;
                        NXOpen.Face face1 = (NXOpen.Face)component01[0].FindObject(ConstNames1[k]);
                        NXOpen.Positioning.ConstraintReference constraintReference1;
                        constraintReference1 = componentConstraint1[k].CreateConstraintReference(component01[0], face1, false, false, false);
                        component01[1]       = (NXOpen.Assemblies.Component)nxSubAssem.ComponentAssembly.RootComponent.FindObject("COMPONENT " + partname[1] + " 1");
                        NXOpen.Face face2 = (NXOpen.Face)component01[1].FindObject(ConstNames2[k]);
                        //Face face3 = (NXOpen.Face)component01[1].FindObject(ConstNames2[1]);
                        NXOpen.Positioning.ConstraintReference constraintReference2;
                        constraintReference2 = componentConstraint1[k].CreateConstraintReference(component01[1], face2, false, false, false);
                    }
                    else
                    {
                        componentPositioner2[k] = nxSubAssem.ComponentAssembly.Positioner;
                        componentPositioner2[k].BeginAssemblyConstraints();
                        Constraint constraint1;
                        constraint1             = componentPositioner2[k].CreateConstraint(true);
                        componentConstraint2[k] = (NXOpen.Positioning.ComponentConstraint)constraint1;
                        //componentConstraint2[k].ConstraintAlignment = NXOpen.Positioning.Constraint.Alignment.InferAlign;
                        componentConstraint2[k].ConstraintType = NXOpen.Positioning.Constraint.Type.Touch;
                        NXOpen.Face face1 = (NXOpen.Face)component01[0].FindObject(ConstNames1[k]);
                        NXOpen.Positioning.ConstraintReference constraintReference3;
                        constraintReference3 = componentConstraint2[k].CreateConstraintReference(component01[0], face1, false, false, false);
                        component01[1]       = (NXOpen.Assemblies.Component)nxSubAssem.ComponentAssembly.RootComponent.FindObject("COMPONENT " + partname[1] + " 1");
                        NXOpen.Face face2 = (NXOpen.Face)component01[1].FindObject(ConstNames2[k]);
                        NXOpen.Positioning.ConstraintReference constraintReference4;
                        constraintReference4 = componentConstraint2[k].CreateConstraintReference(component01[1], face2, false, false, false);
                        constraintReference4.SetFixHint(true);
                    }
                }
                break;
            }
            PartSaveStatus fileSave;

            fileSave = nxRootAssem.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False);
        }