ifcpatch

Subpackages

Package Contents

class ifcpatch.ArgumentsDict

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

Initialize self. See help(type(self)) for accurate signature.

arguments: typing_extensions.NotRequired[Sequence[Any]]
file: typing_extensions.NotRequired[ifcopenshell.file]
input: typing_extensions.NotRequired[str]
log: typing_extensions.NotRequired[str]
recipe: str
class ifcpatch.DocstringData

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

Initialize self. See help(type(self)) for accurate signature.

description: str
filter_glob: dict[str, str]
name: str
output: str | None
param: dict[str, str]
class ifcpatch.InputDoc

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

Initialize self. See help(type(self)) for accurate signature.

default: typing_extensions.NotRequired[Any]
description: str
enum_items: typing_extensions.NotRequired[list[str]]
filter_glob: typing_extensions.NotRequired[str]
generic_type: typing_extensions.NotRequired[str]
name: str
type: str | list[str]
class ifcpatch.PatcherDoc

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

Initialize self. See help(type(self)) for accurate signature.

class_: type
description: str
inputs: dict[str, InputDoc]
output: str | None
ifcpatch.execute(args: ArgumentsDict) ifcopenshell.file | str

Execute a patch recipe

The details of how the patch recipe is executed depends on the definition of the recipe, as well as the arguments passed to the recipe. See the documentation for each patch recipe separately to understand more.

Parameters:
  • args (ArgumentsDict) – A dictionary of arguments, corresponding to the parameters listed subsequent to this in this docstring.

  • file (ifcopenshell.file, optional) – An IFC model to apply the patch recipe to. Required for most recipes except the ones that require input.

  • input (str, optional) – A filepath to the incoming IFC file. Required/supported only for some recipes, see specific recipes descriptions, in other cases will be ignored.

  • recipe (str) – The name of the recipe. This is the same as the filename of the recipe. E.g. “ExtractElements”.

  • log (str,optional) – A filepath to a logfile.

  • arguments (list) – A list of zero or more positional arguments, depending on the patch recipe. Some patch recipes will require you to specify arguments, some won’t.

Returns:

The result of the patch. This is typically a patched model, either as an object or as a string.

Example:

output = ifcpatch.execute({
    "input": "input.ifc",
    "file": ifcopenshell.open("input.ifc"),
    "recipe": "ExtractElements",
    "arguments": [".IfcWall"],
})
ifcpatch.write(output, "output.ifc")
ifcpatch.extract_docs(submodule_name: str, cls_name: str, method_name: str = '__init__', boilerplate_args: Sequence[str] | None = None) PatcherDoc | None

Extract class docstrings and method arguments

Parameters:
  • submodule_name – Submodule from which to extract the class

  • cls_name – Class from which to extract the docstring and method arguments

  • method_name – Class Method name from which to extract arguments

  • boilerplate_args – String iterable containing arguments that shall not be parsed

ifcpatch.parse_docstring(docstring: str) DocstringData
ifcpatch.write(output: ifcopenshell.file | str, filepath: str) None

Write the output of an IFC patch to a file

Typically a patch output would be a patched IFC model file object, or as a string. This function lets you agnostically write that output to a filepath.

Parameters:
  • output (ifcopenshell.file.file,str) – The results from ifcpatch.execute()

  • filepath (str) – A filepath to where the results of the patched model should be written to.

Returns:

None

Return type:

None