예제 #1
0
        public void DrawLines()
        {
            var activemodel = Program.GetActiveDgnModel();

            //Create ItemTypeLibrary
            BD.ItemTypeLibrary pilePropItemTypeLibrary = CreateItemTypeLibrary();

            //Create PileAxisLevelHandle
            var pileaxislevelhandle = CreatePileAxisLevel();

            if (pileaxislevelhandle == null)
            {
                return;
            }
            BM.SettingsActivator.SetActiveLevel(pileaxislevelhandle.LevelId);
            BD.ElementPropertiesSetter levelSetter = new BD.ElementPropertiesSetter();
            levelSetter.SetLevel(pileaxislevelhandle.LevelId);

            //Get the PileAxisInfomation And Create the Pile and Schedule Itemtype
            var pileAxisInfoList = ExtractPileAxisInfo();

            BG.DPoint3d top, bottom;
            double      uorPerMillimeter = activemodel.GetModelInfo().UorPerMeter / 1000;
            double      tolerance        = 1e-5;

            foreach (var pileAxisInfo in pileAxisInfoList)
            {
                top = BG.DPoint3d.FromXYZ(pileAxisInfo.TopX, pileAxisInfo.TopY, pileAxisInfo.TopZ);
                if (Math.Abs(pileAxisInfo.Skewness) < tolerance)
                {
                    bottom = top - BG.DPoint3d.UnitY * pileAxisInfo.Length;
                }
                else
                {
                    double temp = pileAxisInfo.Length / (Math.Sqrt(pileAxisInfo.Skewness * pileAxisInfo.Skewness + 1));
                    bottom = top + new BG.DPoint3d(Math.Cos(pileAxisInfo.RotationDegree * deg2rad), Math.Sin(pileAxisInfo.RotationDegree * deg2rad), -pileAxisInfo.Skewness) * temp;
                }
                top.ScaleInPlace(uorPerMillimeter);
                bottom.ScaleInPlace(uorPerMillimeter);

                BG.DSegment3d   lineDSegment3D = new BG.DSegment3d(top, bottom);
                BDE.LineElement line           = new BDE.LineElement(activemodel, null, lineDSegment3D);
                levelSetter.Apply(line);

                if (SetLineElementProp(pileAxisInfo, line, pilePropItemTypeLibrary) == BD.StatusInt.Error)
                {
                    BM.MessageCenter.Instance.ShowErrorMessage($"{pileAxisInfo.PileCode}桩写入属性失败", "写入属性失败", false);
                    continue;
                }
                line.AddToModel();
            }
        }
예제 #2
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();
            }
        }
예제 #3
0
        public void DrawCollisionIndicator()
        {
            var newlevelhandle = AddLevelByName("Collision");
            var levelsetter    = new BD.ElementPropertiesSetter();

            levelsetter.SetLevel(newlevelhandle.LevelId);
            levelsetter.SetColor(6);
            levelsetter.SetThickness(10, true);

            var activemodel = Program.GetActiveDgnModel();

            foreach (var collision in CollisionResult)
            {
                var line = new BDE.LineElement(activemodel, null, new BG.DSegment3d(collision.PileACollisionPoint, collision.PileBCollisionPoint));
                levelsetter.Apply(line);
                line.AddToModel();
            }
            BM.SettingsActivator.SetActiveLevel(newlevelhandle.LevelId);
            System.Windows.Forms.MessageBox.Show("碰撞交线已绘制在图层[Collision]中");
        }