function groupData(data) { let tmps = []; let obj = {}; data.forEach((item) => { let setName = item.propertySetName; if (!obj[setName]) { obj[setName] = []; } obj[setName].push(item); }); for (let key in obj) { tmps.push({ name: key, data: obj[key], }); } return tmps; } //清除选中构件样式 function clearSelectFeature(that) { let api = bimBriefingApi; if (that.selFeatureId) { let modelId = that.selFeatureId.split("^")[0]; api.Feature.setColor(that.selFeatureId, "rgba(255,255,255,1)", modelId); that.selFeatureId = ""; } } //查询构件属性信息 function dataFiltering(that, id) { const gild = id.split("^"); let modelName = ""; that.models.forEach((item) => { if (item.gis?.lightweightName == gild[0]) { modelName = item.gis.name; } }); if (!modelName || !gild[1]) { return false; } let featureId = gild[1].split("_")[0]; that.$api.bim.modelPropertyByExternalId(gild[0], featureId).then((d) => { let tmps = d.data || []; that.propertyAttr = groupData(tmps.filter((d) => d.propertyTypeName == "properties")); that.propertyType = groupData(tmps.filter((d) => d.propertyTypeName != "properties")); that.propertyLoad = "end"; }); } /** * 获取构件属性信息 */ function getProperty(that) { let api = bimBriefingApi; api.Feature.getByEvent(true, (n) => { console.log(n); if (n && n["id"]) { let featureId = n.id; if (featureId.split("^")[1]) { let modelId = featureId.split("^")[0]; clearSelectFeature(that); api.Feature.setColor(featureId, "rgba(255,0,255,1)", modelId); that.selFeatureId = featureId; dataFiltering(that, featureId); that.propertyLoad = "start"; that.attributeInformation = "查询中,请稍候~"; } } else { that.attributeInformation = "未选中构件"; } }); } /** * 获取构件尺寸信息 */ function subFeatureSize(that) { let api = bimBriefingApi; that.info = []; api.Public.clearHandler(), api.Measurement.clearAllTrace(); api.Feature.getByEvent(true, (n) => { console.log(n); if (n && n["id"]) { let featureId = n.id; let modelId = featureId.split("^")[0]; clearSelectFeature(that); api.Feature.getGeometrySizeById(featureId, (res) => { let size = res.size || {}; that.info = [ { name: "长", value: (size.x || 0).toFixed(2) + "" }, { name: "宽", value: (size.y || 0).toFixed(2) + "" }, { name: "高", value: (size.z || 0).toFixed(2) + "" }, ]; api.Feature.setColor(featureId, "rgba(255,0,255,1)", modelId); that.selFeatureId = featureId; }); } }); } //构件面积 function measurementArea(that) {} //构件体积 function measuringVolume(that){ } //构件距离 function distance(that){ } //剖切 function initClipping(that){ } //构件隐藏 function actorVisible(){ } export default { measurementArea, clearSelectFeature, getProperty, subFeatureSize, measuringVolume, distance, initClipping, actorVisible, };