예제 #1
0
 BD.ItemTypeLibrary CreateItemTypeLibrary()
 {
     BD.ItemTypeLibrary library = BD.ItemTypeLibrary.FindByName("PDIWT_ZJCZL", Program.GetActiveDgnFile());
     if (library == null)
     {
         library = BD.ItemTypeLibrary.Create("PDIWT_ZJCZL", Program.GetActiveDgnFile());
         BD.ItemType       pile         = library.AddItemType("PileProperty");
         BD.CustomProperty pileProperty = pile.AddProperty("PileType");
         pileProperty.Type         = BD.CustomProperty.TypeKind.String;
         pileProperty.DefaultValue = "实心桩或桩端封闭";
         var pileCrossSection = pile.AddProperty("PileCrossSectionType");
         pileCrossSection.Type         = BD.CustomProperty.TypeKind.String;
         pileCrossSection.DefaultValue = "方形截面";
         var pileCode = pile.AddProperty("PileAxisNet(H-V)");
         pileCode.Type = BD.CustomProperty.TypeKind.String;
         var pileSideLength = pile.AddProperty("PileSideLength(m)");
         pileSideLength.Type         = BD.CustomProperty.TypeKind.Double;
         pileSideLength.DefaultValue = 1;
         var pileInnerSideLength = pile.AddProperty("PileInnerSideLength(m)");
         pileInnerSideLength.Type         = BD.CustomProperty.TypeKind.Double;
         pileInnerSideLength.DefaultValue = 1;
         var pileWeigth = pile.AddProperty("PileWeigth(kN/m)");
         pileWeigth.Type         = BD.CustomProperty.TypeKind.Double;
         pileWeigth.DefaultValue = 25;
         var pileUnderWaterWeight = pile.AddProperty("PileUnderWaterWeigth(kN/m)");
         pileUnderWaterWeight.Type         = BD.CustomProperty.TypeKind.Double;
         pileUnderWaterWeight.DefaultValue = 15;
         library.Write();
     }
     return(library);
 }
예제 #2
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();
            }
        }
예제 #3
0
        private BD.StatusInt SetLineElementProp(PileAxisInfo pileAxisInfo, BDE.LineElement lineElement, BD.ItemTypeLibrary library)
        {
            BD.ItemType pileItemType = library.GetItemTypeByName("PileProperty");
            if (pileItemType == null)
            {
                return(BD.StatusInt.Error);
            }
            BD.CustomItemHost pileAxisHost = new BD.CustomItemHost(lineElement, true);
            var pileAxisPropInstance       = pileAxisHost.ApplyCustomItem(pileItemType);

            if (pileAxisPropInstance == null)
            {
                return(BD.StatusInt.Error);
            }
            pileAxisPropInstance.SetString(propertStrings[0], piletypeStringDictionary[pileAxisInfo.Type]);
            pileAxisPropInstance.SetString(propertStrings[1], pileCrossSectionDictionary[pileAxisInfo.CrossSectionType]);
            pileAxisPropInstance.SetString(propertStrings[2], pileAxisInfo.PileCode);
            pileAxisPropInstance.SetDouble(propertStrings[3], pileAxisInfo.SideLength);
            pileAxisPropInstance.SetDouble(propertStrings[4], pileAxisInfo.InnerSideLength);
            pileAxisPropInstance.SetDouble(propertStrings[5], pileAxisInfo.Weight);
            pileAxisPropInstance.SetDouble(propertStrings[6], pileAxisInfo.UnderWaterWeight);
            return(pileAxisPropInstance.ScheduleChanges(lineElement));
        }