()
| 104 | |
| 105 | |
| 106 | def main(): |
| 107 | parser = argparse.ArgumentParser( |
| 108 | prog="ifcquery", |
| 109 | description="Query and inspect IFC building models", |
| 110 | ) |
| 111 | parser.add_argument("ifc_file", help="Path to the IFC file") |
| 112 | parser.add_argument( |
| 113 | "--format", |
| 114 | choices=["json", "text", "ids"], |
| 115 | default="json", |
| 116 | dest="output_format", |
| 117 | help="Output format: json (default), text (human-readable), ids (comma-separated step IDs)", |
| 118 | ) |
| 119 | |
| 120 | subparsers = parser.add_subparsers(dest="command", required=True) |
| 121 | |
| 122 | subparsers.add_parser("summary", help="Model overview: schema, element counts, project info") |
| 123 | |
| 124 | subparsers.add_parser("tree", help="Spatial hierarchy tree") |
| 125 | |
| 126 | info_parser = subparsers.add_parser("info", help="Deep inspection of a specific element") |
| 127 | info_parser.add_argument("element_id", help="Element step ID (e.g. 123 or #123)") |
| 128 | |
| 129 | select_parser = subparsers.add_parser("select", help="Filter elements using selector syntax") |
| 130 | select_parser.add_argument("query", help="Selector query string") |
| 131 | |
| 132 | relations_parser = subparsers.add_parser("relations", help="Show relationships for an element") |
| 133 | relations_parser.add_argument("element_id", help="Element step ID (e.g. 123 or #123)") |
| 134 | relations_parser.add_argument("--traverse", choices=["up"], help="Traverse hierarchy (up: walk to IfcProject)") |
| 135 | |
| 136 | clash_parser = subparsers.add_parser("clash", help="Check element placement for clashes") |
| 137 | clash_parser.add_argument("element_id", help="Element step ID (e.g. 123 or #123)") |
| 138 | clash_parser.add_argument("--clearance", type=float, help="Minimum clearance distance") |
| 139 | clash_parser.add_argument("--tolerance", type=float, default=0.002, help="Intersection tolerance (default: 0.002)") |
| 140 | clash_parser.add_argument( |
| 141 | "--scope", choices=["storey", "all"], default="storey", help="Scope of elements to check (default: storey)" |
| 142 | ) |
| 143 | |
| 144 | validate_parser = subparsers.add_parser("validate", help="Schema/constraint validation") |
| 145 | validate_parser.add_argument( |
| 146 | "--rules", action="store_true", help="Also check EXPRESS rules (slower, default: false)" |
| 147 | ) |
| 148 | |
| 149 | schedule_parser = subparsers.add_parser("schedule", help="List work plans and tasks from the model") |
| 150 | schedule_parser.add_argument( |
| 151 | "--depth", type=int, default=None, metavar="N", help="Limit subtask expansion to N levels (default: unlimited)" |
| 152 | ) |
| 153 | |
| 154 | cost_parser = subparsers.add_parser("cost", help="List cost schedules and cost items from the model") |
| 155 | cost_parser.add_argument( |
| 156 | "--depth", |
| 157 | type=int, |
| 158 | default=None, |
| 159 | metavar="N", |
| 160 | help="Limit cost item expansion to N levels (default: unlimited)", |
| 161 | ) |
| 162 | |
| 163 | subparsers.add_parser("contexts", help="List geometric representation contexts and subcontexts") |
no test coverage detected