Esempio n. 1
0
        public static void createCutLavorazione(PartDocument oDoc, List <string> nomeSketch)
        {
            SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition;

            foreach (string nameS in nomeSketch)
            {
                try
                {
                    PlanarSketch oSketch = oCompDef.Sketches[nameS];

                    SheetMetalFeatures oSheetMetalFeatures = (SheetMetalFeatures)oCompDef.Features;

                    Profile oProfile = oSketch.Profiles.AddForSolid();

                    CutDefinition oCutDefinition = oSheetMetalFeatures.CutFeatures.CreateCutDefinition(oProfile);

                    //oCutDefinition.SetThroughAllExtent(PartFeatureExtentDirectionEnum.kNegativeExtentDirection);

                    CutFeature oCutFeature = oSheetMetalFeatures.CutFeatures.Add(oCutDefinition);
                }
                catch
                {
                    throw new Exception("Nome sketch non esiste: " + nameS);
                }
            }
        }
Esempio n. 2
0
        static public void offsetAdaptive(SheetMetalComponentDefinition smcd, string name, double valA, double valB, double valB1)
        {
            double       a = valA, b = valB;
            PlanarSketch ps        = smcd.Sketches[name];
            PlanarSketch newSketch = smcd.Sketches.Add(ps.PlanarEntity);

            name = newSketch.Name;
            Profile profiles = ps.Profiles.AddForSolid();

            foreach (ProfilePath pr in profiles)
            {
                bool flag = cmpLen(pr, valB1 - 0.03);
                if (flag)
                {
                    b = valB1;/*Convert.ToDouble(this.textBox3.Text.Replace(',', separator)) / 10;*/
                }
                if (pr.Count == 4)
                {
                    ProfileEntity pe1 = (ProfileEntity)pr[1];
                    ProfileEntity pe3 = (ProfileEntity)pr[3];
                    if (pe1.CurveType != Curve2dTypeEnum.kLineSegmentCurve2d || pe1.EndSketchPoint.Geometry.DistanceTo(pe1.StartSketchPoint.Geometry) > valA * 2)
                    {
                        pe1 = (ProfileEntity)pr[2]; pe3 = (ProfileEntity)pr[4];
                    }
                    //pe1.SketchEntity.Construction = true;

                    //ProfileEntity pe1 = pr.OfType<ProfileEntity>().FirstOrDefault(e1 => e1.CurveType == Curve2dTypeEnum.kLineCurve2d &&
                    //    (e1.EndSketchPoint.Geometry.DistanceTo(e1.StartSketchPoint.Geometry) <= 0.1));
                    //ProfileEntity pe3 = pr.OfType<ProfileEntity>().LastOrDefault(e1 => e1.CurveType == Curve2dTypeEnum.kLineCurve2d &&
                    //    (e1.EndSketchPoint.Geometry.DistanceTo(e1.StartSketchPoint.Geometry) <= 0.1));
                    if (pe1 == null || pe3 == null)
                    {
                        continue;
                    }


                    //SketchLine sl1 = (SketchLine)pe1.SketchEntity;
                    //SketchLine sl2 = (SketchLine)pe3.SketchEntity;

                    SketchLine sl1 = (SketchLine)newSketch.AddByProjectingEntity(pe1.SketchEntity);
                    SketchLine sl2 = (SketchLine)newSketch.AddByProjectingEntity(pe3.SketchEntity);

                    //sl2.Construction = true;
                    SketchLine         sl3 = midleLine(sl1, sl2);
                    SketchPoint        mp  = newSketch.SketchPoints.Add(sl3.Geometry.MidPoint, false);
                    MidpointConstraint mpc = newSketch.GeometricConstraints.AddMidpoint(mp, sl3);
                    //SketchBlock sb;
                    //SketchLine newLin;
                    //if (b == valB)
                    //{
                    //    sb = ps.SketchBlocks.AddByDefinition(smcd.SketchBlockDefinitions["Паз"], mp.Geometry);
                    //}
                    //else
                    //{
                    //    sb = ps.SketchBlocks.AddByDefinition(smcd.SketchBlockDefinitions["Паз_замыкающий"], mp.Geometry);
                    //}
                    //    newLin = ps.SketchLines.OfType<SketchLine>().LastOrDefault(l => l.Construction == true);
                    //    ps.GeometricConstraints.AddCollinear((SketchEntity)newLin, (SketchEntity)sl3);

                    rect(sl3, mp, a, b);
                }
            }
            //foreach (SketchBlock item in ps.SketchBlocks)
            //{
            //    item.Explode();
            //}
            //foreach (DimensionConstraint item in newSketch.DimensionConstraints)
            //{
            //    item.Delete();
            //}
            //addEqualLength(newSketch, valA);
            //addEqualLength(newSketch, valB);
            //addEqualLength(newSketch, valB1);

            CutFeature cut = addCut(smcd, name); cut.Name = "Пазы";
        }
Esempio n. 3
0
        private void Cut_it_Click(object sender, EventArgs e)
        {
            //Cut_Polyline(axMapControl1.Map, flaglayer);
            //ICommand pCommand = new CutFeature();
            //pCommand.OnCreate(axMapControl1.Object);
            //axMapControl1.CurrentTool = pCommand as ITool;
            IMap Cmap = this.axMapControl1.Map;
            ILayer CLayer = getLayerByName(Cmap, toolStripComboBox2.Text);

            IEnumFeature enumFeature = Cmap.FeatureSelection as IEnumFeature;
            IFeature CFeature = enumFeature.Next();
            IPolyline CutPolyline = CFeature.Shape as IPolyline;

            ICommand pCommand = new CutFeature(CLayer, Cmap, CutPolyline);
            pCommand.OnCreate(axMapControl1.Object);
            axMapControl1.CurrentTool = pCommand as ITool;
        }