SOURCE

console 命令行工具 X clear

                    
>
console
document.getElementById('btn').addEventListener('click', function() {
    let text = document.getElementById('text').value;
    // 去掉所有引号内的空格
    text = text.replace(/"\s*([^ "]*)\s*"/, '"$1"');
    // 去掉所有tab、多个空格
    text = text.replace(/\s+/, ' ');
    // alert(text);
    // 拼接snl
    let result = `
<?xml version="1.0" encoding="UTF-8"?>
<rule_lib>
  <lib_name>单条合并.snl</lib_name>
  <lib_info />
  <ontology />
  <class_set>
    <class id="0">
      <class_name>所有规则</class_name>
      <class_number />
    </class>
    <class id="0,1">
      <class_name>分类1</class_name>
      <class_number>1</class_number>
    </class>
    <class id="0,0">
      <class_name>未分类</class_name>
      <class_number />
    </class>
  </class_set>
  <resource_set />
  <group_set>
    <group_introduction />
  </group_set>
  <rule_set>
    <rule_introduction />
    <rule id="1">
      <whichclass>0,1</whichclass>
      <rule_number>1</rule_number>
      <resourceName>;</resourceName>
      <rule_group />
      <rule_nat_descpt>规则1</rule_nat_descpt>
      <rule_anot_descpt />
    </rule>
  </rule_set>
  <fml_descpt_set>
  ${
      text.split('\n').map((row, i) => {

          return `
            <fml_descpt id="${i+1}">
                <ruleId>${i+1}</ruleId>
                <descpt_snl>${row}</descpt_snl>
                <descpt_snl_split_text />
            </fml_descpt>
          `;
      }).join('\n')
  }
    <fml_descpt id="1">
      <ruleId>1</ruleId>
      <descpt_snl>所有 建筑 有 门</descpt_snl>
      <descpt_snl_split_text />
    </fml_descpt>
    <fml_descpt id="2">
      <ruleId>1</ruleId>
      <descpt_snl>所有 建筑 有 门</descpt_snl>
      <descpt_snl_split_text />
    </fml_descpt>
  </fml_descpt_set>
  <temporal_descpt_set />
  <note_set />
  <config_set text="墙 = {ifc2x3:ifcwall,ifc2x3:ifcwallstandardcase}&#xD;&#xA;门 = {ifc2x3:ifcdoor,ifc2x3:ifcdoorstandardcase}&#xD;&#xA;洞口 = ifc2x3:ifcopeningelement&#xD;&#xA;窗 = ifc2x3:ifcwindow&#xD;&#xA;楼梯 = ifc2x3:ifcstair&#xD;&#xA;坡道 = ifc2x3:IfcRamp&#xD;&#xA;天花板 = {ifc2x3:ifcceiling,ifc2x3:IfcCovering}&#xD;&#xA;家具 = ifc2x3:IfcFurniture&#xD;&#xA;家具系统 = ifc2x3:IfcSystemFurnitureElement&#xD;&#xA;房间 = ifc2x3:IfcSpace&#xD;&#xA;空间 = ifc2x3:IfcSpace&#xD;&#xA;柱 = ifc2x3:IfcColumn&#xD;&#xA;梁 = ifc2x3:ifcbeam&#xD;&#xA;栏杆扶手 = ifc2x3:IfcRailing&#xD;&#xA;楼板 = ifc2x3:IfcSlab&#xD;&#xA;橱柜 = ifc2x3:IfcFurniture&#xD;&#xA;屋顶 = ifc2x3:IfcRoof&#xD;&#xA;幕墙 = ifc2x3:IfcCurtainWall&#xD;&#xA;标高 =ifc2x3:IfcBuildingStorey&#xD;&#xA;楼层 =ifc2x3:IfcBuildingStorey&#xD;&#xA;管道 = ifc2x3:ifcpipesegment&#xD;&#xA;管件 = ifc2x3:ifcpipefitting&#xD;&#xA;管道附件 = {ifc2x3:ifcpipevalve,ifc2x3:ifcvalve}&#xD;&#xA;管道隔热层 = {ifc2x3:ifcpipecovering,ifc2x3:ifccovering}&#xD;&#xA;软管 = ifc2x3:ifcpipesegment&#xD;&#xA;线管 = ifc2x3:ifccablepipesegment&#xD;&#xA;线管配件 = ifc2x3:ifccablepipefitting&#xD;&#xA;电缆桥架 = ifc2x3:ifccablecarriersegment&#xD;&#xA;电缆桥架配件 = ifc2x3:ifccablecarrierfitting&#xD;&#xA;风管 = ifc2x3:IfcDuctSegment&#xD;&#xA;软风管 = ifc2x3:IfcDuctSegment&#xD;&#xA;风管隔热层 = {ifc2x3:ifcductcovering,ifc2x3:ifccovering}&#xD;&#xA;风管管件 = ifc2x3:IfcDuctFitting&#xD;&#xA;风道末端 = ifc2x3:IfcAirTerminal&#xD;&#xA;风管附件 = {ifc2x3:ifcductvalve,ifc2x3:ifcvalve}&#xD;&#xA;风管系统 = {ifc2x3:ifcductsystem,ifc2x3:ifcsystem}&#xD;&#xA;管道系统 = {ifc2x3:ifcpipesystem,ifc2x3:ifcsystem}&#xD;&#xA;照明设备 = ifc2x3:ifclightfixture&#xD;&#xA;卫浴装置 = ifc2x3:ifcsanitaryterminal&#xD;&#xA;机械设备 = {ifc2x3:ifcmechanicalappliance,ifc2x3:ifcbuildingelementproxy}&#xD;&#xA;电话设备 = ifc2x3:IfcElectricAppliance&#xD;&#xA;火警设备 = ifc2x3:IfcAlarm&#xD;&#xA;结构基础 = ifc2x3:IfcFooting&#xD;&#xA;结构柱 = ifc2x3:IfcColumn&#xD;&#xA;结构框架 = {ifc2x3:ifcstructuralframe,ifc2x3:ifcbuildingelementproxy}&#xD;&#xA;结构钢筋网 = ifc2x3:IfcReinforcementMesh&#xD;&#xA;结构钢筋网区域 = ifc2x3:IfcGroup&#xD;&#xA;结构梁系统 = ifc2x3:IfcAssembly&#xD;&#xA;结构桁架 = ifc2x3:IfcAssembly&#xD;&#xA;结构钢筋 = ifc2x3:IfcReinforcingMesh&#xD;&#xA;结构区域钢筋 = ifc2x3:IfcReinforcingBar&#xD;&#xA;结构路径钢筋 = ifc2x3:IfcReinforcingBar&#xD;&#xA;常规模型 = {ifc2x3:model,ifc2x3:ifcbuildingelementproxy}&#xD;&#xA;场地 = ifc2x3:IfcSlab&#xD;&#xA;组成部分 = ifc2x3:IfcBuildingElementPart&#xD;&#xA;喷头 = ifc2x3:IfcFireSuppressionTerminal&#xD;&#xA;数据设备 = ifc2x3:IfcElectricAppliance&#xD;&#xA;护理呼叫设备 = ifc2x3:IfcSwitchingDevice&#xD;&#xA;专用设备 = {ifc2x3:ifcspecialappliance,ifc2x3:IfcBuildingElementProxy}&#xD;&#xA;建筑 = ifc2x3:ifcbuilding&#xD;&#xA;面积 = ifc2x3:ifcarea&#xD;&#xA;" />
  <alias_set text="" />
  <selected_rules />
</rule_lib>`;

    // 提供下载
    let filename = '单条合并.snl';
    var blob = new Blob([result], {type: 'text/plain'});
    if(window.navigator.msSaveOrOpenBlob) {
        window.navigator.msSaveBlob(blob, filename);
    }
    else{
        var elem = window.document.createElement('a');
        elem.href = window.URL.createObjectURL(blob);
        elem.download = filename;        
        document.body.appendChild(elem);
        elem.click();        
        document.body.removeChild(elem);
    }
});
粘贴SNL内容(一行一个)<br />
<textarea id="text">

</textarea>
<br />
<button id="btn">
    生成
</button>