Ejemplo n.º 1
0
 internal static Snap.NX.ThroughCurves CreateThroughCurves(Snap.NX.ICurve[] icurves)
 {
     Snap.NX.Section[] sectionArray = new Snap.NX.Section[icurves.Length];
     for (int i = 0; i < icurves.Length; i++)
     {
         sectionArray[i] = Snap.NX.Section.CreateSection(new Snap.NX.ICurve[] { icurves[i] });
     }
     if (sectionArray.Length == 0)
     {
         return(null);
     }
     NXOpen.Features.ThroughCurvesBuilder featureBuilder = Globals.NXOpenWorkPart.Features.CreateThroughCurvesBuilder(null);
     featureBuilder.Alignment.AlignCurve.DistanceTolerance  = Globals.DistanceTolerance;
     featureBuilder.Alignment.AlignCurve.ChainingTolerance  = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
     featureBuilder.SectionTemplateString.DistanceTolerance = Globals.DistanceTolerance;
     featureBuilder.SectionTemplateString.ChainingTolerance = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
     featureBuilder.Alignment.AlignCurve.AngleTolerance     = Globals.AngleTolerance;
     featureBuilder.SectionTemplateString.AngleTolerance    = Globals.AngleTolerance;
     NXOpen.Section[] sections = new NXOpen.Section[sectionArray.Length];
     for (int j = 0; j < sectionArray.Length; j++)
     {
         sections[j] = (NXOpen.Section)sectionArray[j];
         featureBuilder.SectionsList.Append(sections[j]);
     }
     featureBuilder.Alignment.SetSections(sections);
     Snap.NX.ThroughCurves curves = (NXOpen.Features.ThroughCurves)Snap.NX.Feature.CommitFeature(featureBuilder);
     featureBuilder.Destroy();
     return(curves);
 }
Ejemplo n.º 2
0
    private void CreateExtrude(IBaseCurve[] curves, bool add, double distance, Vector3d vector)
    {
        SelectionIntentRule[] rules = new SelectionIntentRule[1]
        {
            workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves)
        };

        NXOpen.Features.ExtrudeBuilder extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(null);
        NXOpen.Section section1 = workPart.Sections.CreateSection(0.0095, 0.01, 0.5);
        section1.AddToSection(rules, (Curve)curves[0], null, null, new Point3d(0, 0, 0), Section.Mode.Create, false);
        extrudeBuilder1.Section = section1;

        if (add)
        {
            extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
        }
        else
        {
            extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Subtract;

            extrudeBuilder1.BooleanOperation.SetTargetBodies(new Body[1] {
                workPart.Bodies.ToArray()[0]
            });
        }
        distance = distance / 2.0;
        extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "-" + distance.ToString();
        extrudeBuilder1.Limits.EndExtend.Value.RightHandSide   = distance.ToString();

        NXOpen.Point3d origin1 = new NXOpen.Point3d(0.0, 0, 0);
        extrudeBuilder1.Direction = workPart.Directions.CreateDirection(origin1, vector, NXOpen.SmartObject.UpdateOption.WithinModeling);

        extrudeBuilder1.CommitFeature();

        extrudeBuilder1.Destroy();
    }
Ejemplo n.º 3
0
 internal static Snap.NX.Section CreateSection(params Snap.NX.Point[] points)
 {
     NXOpen.Section section = Globals.WorkPart.NXOpenPart.Sections.CreateSection(0.02413, Globals.DistanceTolerance, Globals.AngleTolerance);
     section.AllowSelfIntersection(false);
     section.SetAllowedEntityTypes(NXOpen.SectionEx.AllowTypes.CurvesAndPoints);
     SelectionIntentRule[] rules = CreateSelectionIntentRule(points);
     section.AddToSection(rules, (NXOpen.NXObject)points[0].NXOpenTaggedObject, null, null, (Point3d)Position.Origin, NXOpen.Section.Mode.Create);
     return(section);
 }
Ejemplo n.º 4
0
 internal void AddPoints(params Snap.NX.Point[] points)
 {
     if (points != null)
     {
         Snap.NX.Part   workPart      = Globals.WorkPart;
         NXOpen.Section nXOpenSection = this.NXOpenSection;
         nXOpenSection.AllowSelfIntersection(false);
         SelectionIntentRule[] rules = CreateSelectionIntentRule(points);
         nXOpenSection.AddToSection(rules, (NXOpen.NXObject)points[0].NXOpenTaggedObject, null, null, (Point3d)Position.Origin, NXOpen.Section.Mode.Create, false);
     }
 }
Ejemplo n.º 5
0
 internal static Snap.NX.Section CreateSection(params Snap.NX.ICurve[] icurves)
 {
     NXOpen.Section section = Globals.WorkPart.NXOpenPart.Sections.CreateSection(0.02413, Globals.DistanceTolerance, Globals.AngleTolerance);
     section.AllowSelfIntersection(false);
     section.SetAllowedEntityTypes(NXOpen.SectionEx.AllowTypes.CurvesAndPoints);
     for (int i = 0; i < icurves.Length; i++)
     {
         SelectionIntentRule[] rules = CreateSelectionIntentRule(new Snap.NX.ICurve[] { icurves[i] });
         section.AddToSection(rules, (NXOpen.NXObject)icurves[i].NXOpenTaggedObject, null, null, (Point3d)Position.Origin, NXOpen.Section.Mode.Create);
     }
     return(section);
 }
Ejemplo n.º 6
0
 internal void AddICurve(params Snap.NX.ICurve[] icurves)
 {
     if (icurves != null)
     {
         Snap.NX.Part   workPart      = Globals.WorkPart;
         NXOpen.Section nXOpenSection = this.NXOpenSection;
         nXOpenSection.AllowSelfIntersection(false);
         for (int i = 0; i < icurves.Length; i++)
         {
             SelectionIntentRule[] rules = CreateSelectionIntentRule(new Snap.NX.ICurve[] { icurves[i] });
             nXOpenSection.AddToSection(rules, (NXOpen.NXObject)icurves[i].NXOpenTaggedObject, null, null, (Point3d)Position.Origin, NXOpen.Section.Mode.Create, false);
         }
     }
 }
Ejemplo n.º 7
0
 internal static Snap.NX.Ruled CreateRuled(Snap.NX.Curve curve0, Snap.NX.Curve curve1)
 {
     NXOpen.Features.RuledBuilder featureBuilder = Globals.WorkPart.NXOpenPart.Features.CreateRuledBuilder(null);
     featureBuilder.PositionTolerance = Globals.DistanceTolerance;
     featureBuilder.FirstSection.DistanceTolerance  = Globals.DistanceTolerance;
     featureBuilder.FirstSection.ChainingTolerance  = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
     featureBuilder.SecondSection.DistanceTolerance = Globals.DistanceTolerance;
     featureBuilder.SecondSection.ChainingTolerance = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
     featureBuilder.AlignmentMethod.AlignCurve.DistanceTolerance = Globals.DistanceTolerance;
     featureBuilder.AlignmentMethod.AlignCurve.ChainingTolerance = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
     ((Snap.NX.Section)featureBuilder.FirstSection).AddICurve(new Snap.NX.ICurve[] { curve0 });
     ((Snap.NX.Section)featureBuilder.SecondSection).AddICurve(new Snap.NX.ICurve[] { curve1 });
     NXOpen.Section[] sections = new NXOpen.Section[] { featureBuilder.FirstSection, featureBuilder.SecondSection };
     featureBuilder.AlignmentMethod.SetSections(sections);
     NXOpen.Features.Ruled ruled = (NXOpen.Features.Ruled)Snap.NX.Feature.CommitFeature(featureBuilder);
     featureBuilder.Destroy();
     return(new Snap.NX.Ruled(ruled));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 创建拉伸特征
        /// </summary>
        /// <param name="vec">向量</param>
        /// <param name="start">起始</param>
        /// <param name="end">终止</param>
        /// <param name="extrude">lastez</param>
        /// <param name="line">线</param>
        /// <returns></returns>
        public static NXOpen.Features.Feature CreateExtrude(Vector3d vec, string start, string end, NXOpen.Features.Feature extrude = null, params TaggedObject[] line)
        {
            Session theSession         = Session.GetSession();
            Part    workPart           = theSession.Parts.Work;
            SelectionRuleFactory rules = new SelectionRuleFactory(line.ToList());

            NXOpen.Features.Feature        nullNXOpen_Features_Feature = null;
            NXOpen.Features.ExtrudeBuilder extrudeBuilder1             = workPart.Features.CreateExtrudeBuilder(nullNXOpen_Features_Feature);
            NXOpen.Section section1 = workPart.Sections.CreateSection();
            extrudeBuilder1.Section = section1;
            extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = start;
            extrudeBuilder1.Limits.EndExtend.Value.RightHandSide   = end;

            NXOpen.Point3d   origin1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
            NXOpen.Direction direction1;
            direction1 = workPart.Directions.CreateDirection(origin1, vec, NXOpen.SmartObject.UpdateOption.WithinModeling);


            NXOpen.NXObject nullNXOpen_NXObject = null;

            section1.AddToSection(rules.CreateSelectionRule().ToArray(), (NXObject)line[0], nullNXOpen_NXObject, nullNXOpen_NXObject, origin1, NXOpen.Section.Mode.Create, false);
            extrudeBuilder1.Direction = direction1;
            NXOpen.Session.UndoMarkId markId = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start Extruded");
            try
            {
                return(extrudeBuilder1.CommitFeature());
            }

            catch (NXException ex)
            {
                LogMgr.WriteLog("ExtrudedUtils:CreateExtruded:" + ex.Message);
                throw ex;
            }
            finally
            {
                extrudeBuilder1.Destroy();
                theSession.UpdateManager.DoUpdate(markId);
                theSession.DeleteUndoMark(markId, "End Extruded");
            }
        }
Ejemplo n.º 9
0
 private Section(NXOpen.Section section) : base(section)
 {
     this.NXOpenSection = section;
 }