MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / main

Function main

src/ifcedit/ifcedit/__main__.py:201–261  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

199
200
201def main():
202 parser = argparse.ArgumentParser(
203 prog="ifcedit",
204 description="CLI wrapper for ifcopenshell.api IFC model mutation functions",
205 )
206 parser.add_argument(
207 "--format",
208 choices=["json", "text"],
209 default="json",
210 dest="output_format",
211 help="Output format (default: json)",
212 )
213
214 subparsers = parser.add_subparsers(dest="command", required=True)
215
216 # list
217 list_parser = subparsers.add_parser("list", help="List API modules or functions in a module")
218 list_parser.add_argument("module", nargs="?", help="Module name (omit to list all modules)")
219
220 # docs
221 docs_parser = subparsers.add_parser("docs", help="Show full documentation for an API function")
222 docs_parser.add_argument("function_path", help="module.function (e.g. root.create_entity)")
223
224 # run
225 run_parser = subparsers.add_parser("run", help="Execute an API function on an IFC file")
226 run_parser.add_argument("ifc_file", help="Path to the IFC file")
227 run_parser.add_argument("function_path", help="module.function (e.g. root.create_entity)")
228 run_parser.add_argument("-o", "--output", help="Output file path (default: overwrite input)")
229 run_parser.add_argument("--dry-run", action="store_true", help="Validate without executing or saving")
230
231 # foreach
232 foreach_parser = subparsers.add_parser(
233 "foreach",
234 help="Apply an API function to each element in a JSON array read from stdin",
235 )
236 foreach_parser.add_argument("ifc_file", help="Path to the IFC file")
237 foreach_parser.add_argument("function_path", help="module.function (e.g. attribute.edit_attributes)")
238 foreach_parser.add_argument("-o", "--output", help="Output file path (default: overwrite input)")
239
240 # quantify
241 quantify_parser = subparsers.add_parser("quantify", help="Quantity take-off (QTO) using ifc5d rules")
242 quantify_sub = quantify_parser.add_subparsers(dest="quantify_command")
243 quantify_sub.add_parser("list", help="List available QTO rule names")
244 qrun_parser = quantify_sub.add_parser("run", help="Run QTO on an IFC file")
245 qrun_parser.add_argument("ifc_file", help="Path to the IFC file")
246 qrun_parser.add_argument("rule_name", help="QTO rule name (e.g. IFC4QtoBaseQuantities)")
247 qrun_parser.add_argument("--selector", help="ifcopenshell selector to restrict elements (default: all IfcElement)")
248 qrun_parser.add_argument("-o", "--output", help="Output file path (default: overwrite input)")
249
250 args, extra = parser.parse_known_args()
251
252 if args.command == "list":
253 cmd_list(args)
254 elif args.command == "docs":
255 cmd_docs(args)
256 elif args.command == "run":
257 cmd_run(args, extra)
258 elif args.command == "foreach":

Callers 1

__main__.pyFile · 0.70

Calls 5

cmd_listFunction · 0.85
cmd_docsFunction · 0.85
cmd_runFunction · 0.85
cmd_foreachFunction · 0.85
cmd_quantifyFunction · 0.85

Tested by

no test coverage detected