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

Method ifc_shape

src/ifcmcp/ifcmcp/core.py:466–494  ·  view source on GitHub ↗

Call a ShapeBuilder method by name. Returns the created entity's step ID. params is a JSON string of keyword arguments. Pass entity references as integer step IDs; vectors as JSON arrays (e.g. [1.0, 0.0, 0.0]).

(self, method: str, params: Any = "{}")

Source from the content-addressed store, hash-verified

464 return _shape_method_docs(method)
465
466 def ifc_shape(self, method: str, params: Any = "{}") -> dict:
467 """Call a ShapeBuilder method by name. Returns the created entity's step ID.
468
469 params is a JSON string of keyword arguments. Pass entity references as integer
470 step IDs; vectors as JSON arrays (e.g. [1.0, 0.0, 0.0]).
471 """
472 model = self._require_model()
473
474 from ifcopenshell.util.shape_builder import ShapeBuilder
475
476 if method.startswith("_"):
477 raise IfcSessionError(f"Private method '{method}' is not accessible")
478 fn = getattr(ShapeBuilder, method, None)
479 if fn is None:
480 return {"ok": False, "error": f"ShapeBuilder has no method '{method}'"}
481
482 if isinstance(params, str):
483 raw_kwargs = json.loads(params) if params.strip() else {}
484 elif isinstance(params, dict):
485 raw_kwargs = params
486 else:
487 raw_kwargs = {}
488
489 try:
490 coerced = _coerce_shape_params(fn, raw_kwargs, model)
491 result = fn(ShapeBuilder(model), **coerced)
492 return {"ok": True, "result": _jsonify(result)}
493 except Exception as e:
494 return {"ok": False, "error": f"{type(e).__name__}: {e}"}
495
496 def ifc_quantify(self, rule: str, selector: str = "") -> dict[str, Any]:
497 """Run quantity take-off on the model using the named rule.

Calls 7

_require_modelMethod · 0.95
ShapeBuilderClass · 0.90
IfcSessionErrorClass · 0.85
_coerce_shape_paramsFunction · 0.85
fnFunction · 0.85
_jsonifyFunction · 0.85
typeFunction · 0.50