Exemplo n.º 1
0
 public static Point3d DPoint3dToPoint3d(this BG.DPoint3d p, double scale = 1)
 {
     return(new Point3d()
     {
         X = p.X * scale, Y = p.Y * scale, Z = p.Z * scale
     });
 }
Exemplo n.º 2
0
 Point3d DPoint3dToPoint3d(BG.DPoint3d p)
 {
     return(new Point3d()
     {
         X = p.X, Y = p.Y, Z = p.Z
     });
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void DrawLines()
        {
            var activemodel = Program.GetActiveDgnModel();
            var levelcache  = activemodel.GetFileLevelCache();
            var levelhandle = levelcache.GetLevelByName("PileAxis");

            if (levelhandle.Status == BD.LevelCacheErrorCode.CannotFindLevel)
            {
                levelhandle = levelcache.CreateLevel("PileAxis");
            }
            levelcache.Write();
            var leveledithandle = levelhandle.GetEditHandle();

            leveledithandle.Description = "桩的轴中心线";
            BM.SettingsActivator.SetActiveLevel(levelhandle.LevelId);

            BD.ElementPropertiesSetter levelsetter = new BD.ElementPropertiesSetter();
            levelsetter.SetLevel(levelhandle.LevelId);
            levelsetter.SetColor(3);

            BG.DPoint3d top, bottom;
            var         pilelist = ExtractPileInfo();

            foreach (var pile in pilelist)
            {
                top = new BG.DPoint3d(pile.TopX, pile.TopY, pile.TopZ);
                if (pile.Skewness == 0)
                {
                    bottom = top - BG.DPoint3d.UnitZ * pile.Length;
                }
                else
                {
                    double temp = pile.Length / (Math.Sqrt(pile.Skewness * pile.Skewness + 1));
                    bottom = top + new BG.DPoint3d(Math.Cos(pile.RotationDegree * deg2rad), Math.Sin(pile.RotationDegree * deg2rad), -pile.Skewness) * temp;
                }
                BG.DSegment3d   lineseg = new BG.DSegment3d(top * 10, bottom * 10);
                BDE.LineElement line    = new BDE.LineElement(activemodel, null, lineseg);
                levelsetter.Apply(line);

                var wb = new BDE.WriteDataBlock();
                wb.WriteString(pile.PileCode);
                line.AppendLinkage((ushort)BD.ElementLinkageId.String, wb);
                line.AddToModel();
            }
        }
Exemplo n.º 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();
        }