Beispiel #1
0
 protected override bool OnPostLocate(BD.HitPath path, out string cantAcceptReason)
 {
     BDE.Element ele = path.GetHeadElement();
     if (ele.ElementType != BD.MSElementType.Shape)
     {
         cantAcceptReason = Resources.PutArmorToolRejectReason;
         return(false);
     }
     BDE.ShapeElement shape            = ele as BDE.ShapeElement;
     BG.CurveVector   shapeCurveVector = shape.GetCurveVector();
     BG.DTransform3d  world2LoaclDTransform3D;
     BG.DTransform3d  loacl2WorlDTransform3D;
     BG.DRange3d      shapeRange3D;
     if (!shapeCurveVector.IsPlanar(out loacl2WorlDTransform3D, out world2LoaclDTransform3D, out shapeRange3D))
     {
         cantAcceptReason = Resources.PutArmorToolRejectReason2;
         return(false);
     }
     if (!IsRectangel(shapeCurveVector))
     {
         cantAcceptReason = Resources.PutArmorToolRejectReason3;
         return(false);
     }
     return(base.OnPostLocate(path, out cantAcceptReason));
 }
Beispiel #2
0
        private bool IsRectangel(BG.CurveVector curveVector)
        {
            int PointNume;

            if (curveVector.Count != 1 || !curveVector.IsClosedPath || !curveVector.GetPrimitive(0).TryGetLineStringPointCount(out PointNume) || PointNume != 5)
            {
                return(false);
            }
            List <BG.DPoint3d> points = new List <BG.DPoint3d>();

            curveVector.GetPrimitive(0).TryGetLineString(points);
            List <BG.DVector3d> lines = new List <BG.DVector3d>();

            for (int i = 0; i < points.Count - 1; i++)
            {
                lines.Add(BG.DPoint3d.Subtract(points[i + 1], points[i]));
            }
            for (int i = 0; i < lines.Count - 1; i++)
            {
                if (!lines[i].IsPerpendicularTo(lines[i + 1]))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #3
0
 public static void CreateExtrudedSolid()
 {
     BG.CurveVector  curveVector  = BG.CurveVector.CreateDisk(new BG.DEllipse3d(BG.DPoint3d.Zero, BG.DVector3d.UnitX * 300, BG.DVector3d.UnitY * 200), BG.CurveVector.BoundaryType.Outer);
     BG.DgnExtrusion extrusion    = new Bentley.GeometryNET.DgnExtrusion(curveVector, BG.DVector3d.UnitZ * 200, true);
     BDE.Element     extrusionEle = BDE.DraftingElementSchema.ToElement(Program.GetActiveDgnModel(), extrusion, null);
     extrusionEle.AddToModel();
 }
Beispiel #4
0
        public override BD.StatusInt OnElementModify(BDE.Element element)
        {
            BDE.ShapeElement shape = element as BDE.ShapeElement;
            if (shape == null)
            {
                return(BD.StatusInt.Error);
            }
            BG.CurveVector  curveVector = shape.GetCurveVector();
            BG.DTransform3d world2LoaclDTransform3D;
            BG.DTransform3d loacl2WorlDTransform3D;
            BG.DRange3d     shapeRange3D;
            curveVector.IsPlanar(out loacl2WorlDTransform3D, out world2LoaclDTransform3D, out shapeRange3D);
            BG.DMatrix3d       rotMatrix3D = loacl2WorlDTransform3D.Matrix;
            List <BG.DPoint3d> points      = new List <BG.DPoint3d>();

            curveVector.GetPrimitive(0).TryGetLineString(points);

            BG.DSegment3d linex = new BG.DSegment3d(points[0], points[1]);
            BG.DSegment3d liney = new BG.DSegment3d(points[0], points[3]);

            int ucellnum = 0;
            int vcellnum = 0;

            if (isOutRect)
            {
                ucellnum = (int)Math.Ceiling(linex.Length / uaxisoffset);
                vcellnum = (int)Math.Ceiling(liney.Length / vaxisoffset);
            }
            else
            {
                ucellnum = (int)Math.Floor(linex.Length / uaxisoffset);
                vcellnum = (int)Math.Floor(liney.Length / vaxisoffset);
            }

            double ufraction = uaxisoffset / linex.Length;
            double vfraction = vaxisoffset / liney.Length;

            for (int i = 0; i < vcellnum; i++)
            {
                BG.DPoint3d yaxisPoint = liney.PointAtFraction(i * vfraction);
                for (int j = 0; j < ucellnum; j++)
                {
                    BG.DPoint3d  xaxisPoint  = linex.PointAtFraction(j * ufraction);
                    BG.DVector3d xyDVector3D = BG.DVector3d.Add(BG.DPoint3d.Subtract(xaxisPoint, points[0]), BG.DPoint3d.Subtract(yaxisPoint, points[0]));
                    BG.DPoint3d  putPoint3D  = BG.DPoint3d.Add(points[0], xyDVector3D);
                    CellFunction.PlaceCell(new ArmorCellInfo()
                    {
                        CellName  = cellName,
                        CellTrans = rotMatrix3D,
                        Origin    = putPoint3D
                    });
                    Bentley.UI.Threading.DispatcherHelper.DoEvents();
                }
            }
            return(BD.StatusInt.Success);
        }
Beispiel #5
0
        public static void CreateElementUniLine(string unparsed)
        {
            BD.DgnModel activeDgnModel = Program.ActiveDgnModel;
            double      uorPerMe       = activeDgnModel.GetModelInfo().UorPerMaster;
            var         lines          = new BG.DPoint3d[]
            {
                new BG.DPoint3d(0, 0),
                new BG.DPoint3d(100 * uorPerMe, 0),
                new BG.DPoint3d(100 * uorPerMe, 100 * uorPerMe),
                new BG.DPoint3d(0, 100 * uorPerMe),
            };
            var curvePri = BG.CurvePrimitive.CreateLineString(lines);

            BG.DEllipse3d circle    = BG.DEllipse3d.FromCenterRadiusXY(new BG.DPoint3d(50 * uorPerMe, 50 * uorPerMe), 10 * uorPerMe);
            var           curvePriC = BG.CurvePrimitive.CreateArc(circle);

            BG.CurveVector composeCurveVector = new BG.CurveVector(BG.CurveVector.BoundaryType.ParityRegion)
            {
                curvePri, curvePriC
            };
            var ele = BDE.DraftingElementSchema.ToElement(activeDgnModel, composeCurveVector, null);

            ele.AddToModel();
        }