Example #1
0
        /// <summary>
        /// 从实体中得到属性
        /// </summary>
        /// <param name="elem"></param>
        /// <returns>返回的是一个 属性组名-同组下的属性列表 字典</returns>
        private Dictionary <string, List <PropertyData> > GetPropertiesAndLocationFromElement(Element elem)
        {
            Dictionary <string, List <PropertyData> > dictProperties = new Dictionary <string, List <PropertyData> >();

            if (!ExportSetting.SystemSetting.IsExportProperty)
            {
                return(dictProperties);
            }

            // 属性中添加族和类型信息
            var internalProps = new List <PropertyData> {
                new PropertyData {
                    GroupName = "#Internal", Name = "#name", Value = CurrentElement.Name
                }
            };

            if (CurrentElement.Category != null)
            {
                internalProps.Add(new PropertyData {
                    GroupName = "#Internal", Name = "#category", Value = CurrentElement.Category.Name
                });
            }
            internalProps.Add(new PropertyData {
                GroupName = "#Internal", Name = "#guid", Value = CurrentElement.UniqueId
            });
            var fname = GetFamilyName(elem);

            if (!string.IsNullOrEmpty(fname) && !(CurrentElement is MEPCurve))
            {
                internalProps.Add(new PropertyData {
                    GroupName = "#Internal", Name = "#family", Value = fname
                });
            }
            dictProperties["#Internal"] = internalProps;

            if (elem is Wall wall && ExportSetting.SystemSetting.IsExportWallSideArea)
            {
                var innerArea = Math.Round(Tools.GetWallSideFaceArea(wall, false) * Tools.SqrFt2SqrM, 3);
                var outerArea = Math.Round(Tools.GetWallSideFaceArea(wall, true) * Tools.SqrFt2SqrM, 3);

                var sideAreaProps = new List <PropertyData>
                {
                    new PropertyData {
                        GroupName = "算量信息", Name = "内测面积", Value = innerArea.ToString()
                    },
                    new PropertyData {
                        GroupName = "算量信息", Name = "外侧面积", Value = outerArea.ToString()
                    }
                };
                dictProperties["算量信息"] = sideAreaProps;
            }

            // 读取位置信息
            if (InstanceLocation == null)
            {
                InstanceLocation = new Dictionary <string, LocationData>();
            }

            if (!(elem is MEPCurve) && elem.Location is LocationCurve && elem is FamilyInstance)
            {
                var curve     = (elem.Location as LocationCurve).Curve;
                var fi        = (elem as FamilyInstance);
                var curvedata = new CurveData();
                if (curve is Arc arc)
                {
                    curvedata.IsArc          = true;
                    curvedata.Center         = new PointData(arc.Center.X, arc.Center.Y, arc.Center.Z);
                    curvedata.Normal         = new PointData(arc.Normal.X, arc.Normal.Y, arc.Normal.Z);
                    curvedata.StartParameter = arc.GetEndParameter(0);
                    curvedata.EndParameter   = arc.GetEndParameter(1);
                    curvedata.Radius         = arc.Radius;
                    var pt = arc.GetEndPoint(0);
                    curvedata.Points.Add(new PointData(pt.X, pt.Y, pt.Z));
                    pt = arc.GetEndPoint(1);
                    curvedata.Points.Add(new PointData(pt.X, pt.Y, pt.Z));
                }
                else
                {
                    curvedata.IsArc = false;
                    var points = curve.Tessellate();
                    foreach (var point in points)
                    {
                        curvedata.Points.Add(new PointData(point.X, point.Y, point.Z));
                    }
                }

                var faceV = new PointData(fi.FacingOrientation.X, fi.FacingOrientation.Y, fi.FacingOrientation.Z);
                var handV = new PointData(fi.HandOrientation.X, fi.HandOrientation.Y, fi.HandOrientation.Z);

                InstanceLocation[CurrentElement.UniqueId] = new LocationData {
                    LocationCurve = curvedata, FaceVec = faceV, HandVec = handV
                };
            }


            if (elem.Parameters != null)
            {
                foreach (Parameter param in elem.Parameters)
                {
                    string groupName = LabelUtils.GetLabelFor(param.Definition.ParameterGroup);
                    if (string.IsNullOrEmpty(groupName))
                    {
                        groupName = param.Definition.ParameterGroup.ToString();
                    }

                    PropertyData proData = new PropertyData
                    {
                        Name      = param.Definition.Name,
                        GroupName = groupName,
                        Value     = param.StorageType == StorageType.String ? param.AsString() : param.AsValueString()
                    };

                    // 去掉多余的属性
                    if (proData.Name.Contains("Extensions."))
                    {
                        continue;
                    }

                    if (dictProperties.ContainsKey(groupName))
                    {
                        dictProperties[groupName].Add(proData);
                    }
                    else
                    {
                        var listTmp = new List <PropertyData> {
                            proData
                        };
                        dictProperties.Add(groupName, listTmp);
                    }
                }
            }

            if (m_bIsExportCylinderProperty)
            {
                List <Solid>  slds        = GetSolidFromElement(elem);
                List <string> cyFacesInfo = new List <string>();
                foreach (Solid sld in slds)
                {
                    cyFacesInfo.AddRange(GetCylinderFaceInfoFromSolid(sld));
                }
                dictProperties["CylinderFaceData"] = GetUniqueCylinderFacePropertyData(cyFacesInfo);
            }

            return(dictProperties);
        }
Example #2
0
 public TriangleData(PointData pt1, PointData pt2, PointData pt3)
 {
     this.Pt1 = pt1;
     this.Pt2 = pt2;
     this.Pt3 = pt3;
 }
 public LocationData()
 {
     LocationCurve = new CurveData();
     FaceVec       = new PointData();
     HandVec       = new PointData();
 }