# BaseClothing

> Human Generator for Blender documentation. Web version: https://humgen3d.com/docs/api/baseclothing

Inherits from: [PreviewCollectionContent](https://humgen3d.com/docs/api/previewcollectioncontent), [SavableContent](https://humgen3d.com/docs/api/savablecontent)

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L62

Baseclass for changing both footwear and clothing settings.

## Attributes

### pattern

```python
BaseClothing.pattern: PatternSettings
```

*read-only*

Gives access to PatternSettings to add/change patterns on this clothing.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L66

## Methods

### set()

```python
BaseClothing.set(preset: str, context: C = None)
```

Gets called by pcoll_outfit or pcoll_footwear to load the selected outfit.

Parameters:
- `preset` (str): Relative path of the preset to load. Get options from the `get_options` method.
- `context` (C, default None): Blender context. bpy.context if not provided.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L74

### add_obj()

```python
BaseClothing.add_obj(cloth_obj: bpy.types.Object, cloth_type: Literal['pants', 'torso', 'footwear', 'full'], recalculate_weights: bool, context: bpy.types.Context, progress: Optional[Callable[[float], None]] = None) -> str
```

Base method for adding new object to the clothing of this human.

The object can sit on the human in any pose and with any body shape. Its
pose and the body shape are taken out so it fits the unmodified body,
corrective shapekeys are added, it is weight painted and added to the
armature. On this human it keeps looking the way it did.

Parameters:
- `cloth_obj` (bpy.types.Object): Object you want to add to the clothing.
- `cloth_type` (Literal['pants', 'torso', 'footwear', 'full']): Type of clothing as string, defines what kind of corrective shapekeys will be added.
- `recalculate_weights` (bool): Whether to recalculate weights of the vertex groups. Only disable if you manually set the weights.
- `context` (bpy.types.Context): Blender context. bpy.context if not provided.
- `progress` (Optional[Callable[[float], None]], default None): Called with a fraction from 0 to 1 as the conversion advances, for a progress indicator.

Returns: str — How the weights were computed. "closest_point" means the weight solver failed and the weights will need manual cleanup.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L128

### add_obj_steps()

```python
BaseClothing.add_obj_steps(cloth_obj: bpy.types.Object, cloth_type: Literal['pants', 'torso', 'footwear', 'full'], recalculate_weights: bool, context: bpy.types.Context) -> Steps[str]
```

The work of `add_obj` as resumable steps, see `HumGen3D.common.progress`.

Yields the fraction of the work that is done. The object is only changed
in the last step, so a generator that is closed early leaves it as it is.

Parameters:
- `cloth_obj` (bpy.types.Object)
- `cloth_type` (Literal['pants', 'torso', 'footwear', 'full'])
- `recalculate_weights` (bool)
- `context` (bpy.types.Context)

Returns: Steps[str] — How the weights were computed, see `add_obj`.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L163

### deform_cloth_to_human()

```python
BaseClothing.deform_cloth_to_human(context: bpy.types.Context, cloth_obj: bpy.types.Object)
```

Deforms the cloth object to the shape of the active HumGen human.

Mainly meant for internal use, but might be useful. Expects the base
shape of the passed cloth_obj to fit a standard HG human with no
adjustments. Stores the shape that fits the current body proportions and
height of the human in the "Body Proportions" shape key.

See `HumGen3D.human.clothing.garment_fit` for the vertex group and custom
properties a clothing object can use to steer how loosely it is fitted.

Parameters:
- `context` (bpy.types.Context): Blender context.
- `cloth_obj` (bpy.types.Object): cloth object to deform

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L198

### remove()

```python
BaseClothing.remove(remove_masks = True) -> list[str]
```

Removes the cloth objects of this category that are currently on the human.

Parameters:
- `remove_masks`: Remove geometry masks used by this clothing, default True

Returns: list[str] — list of geometry masks that need to be removed

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L232

### save_to_library()

```python
BaseClothing.save_to_library(name: str, for_male: bool = True, for_female: bool = True, open_when_finished: bool = False, category: str = 'Custom', thumbnail: Optional[bpy.types.Image] = None, objects: Optional[list[bpy.types.Object]] = None, context: C = None) -> list[subprocess.Popen]
```

Save the currently active footwear/clothing to the HumGen library.

This will make this item accessible in future projects.

Parameters:
- `name` (str): Name of the item to save.
- `for_male` (bool, default True): Whether to make the item available for male humans. Defaults to True.
- `for_female` (bool, default True): Whether to make the item available for female humans. Defaults to True.
- `open_when_finished` (bool, default False): Whether to open the created .blend files in new windows after saving. Defaults to False.
- `category` (str, default 'Custom'): Category to save the item to. Defaults to "Custom". This is the folder the item will be saved in.
- `thumbnail` (Optional[bpy.types.Image], default None): Image to use as thumbnail for the item. Has to be loaded in Blender. If None, NO thumbnail will be saved.
- `objects` (Optional[list[bpy.types.Object]], default None): Which of the objects in `self.objects` to save. Defaults to all of them.
- `context` (C, default None): Blender context. bpy.context if not provided.

Returns: list[subprocess.Popen] — The background Blender processes that shrink the saved files. The files are complete once these have finished, wait() for them if you use the files right away.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L257

### set_texture_resolution()

```python
BaseClothing.set_texture_resolution(clothing_item: bpy.types.Object, resolution_category: Literal['high', 'medium', 'low'])
```

Sets the texture resolution of the passed clothing to the passed resolution.

Parameters:
- `clothing_item` (bpy.types.Object): Blender object that is currently loaded on this human as clothing.
- `resolution_category` (Literal['high', 'medium', 'low']): Resolution category to set the textures to.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L318

### randomize_colors()

```python
BaseClothing.randomize_colors(cloth_obj: bpy.types.Object, context: C = None)
```

Randomizes the colors of the passed clothing object.

Parameters:
- `cloth_obj` (bpy.types.Object): Blender object that is currently loaded on this human as clothing.
- `context` (C, default None): Blender context. bpy.context if not provided.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L374

### as_dict()

```python
BaseClothing.as_dict() -> dict[str, Any]
```

Returns a dictionary representation of this clothing.

Returns: dict[str, Any] — dict[str, Any]: Dictionary representation of this clothing.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/clothing/base_clothing.py#L425

### set_random()

```python
BaseClothing.set_random(context: C = None, update_ui: bool = False)
```

*inherited from PreviewCollectionContent*

Set this content type to a random content item.

This will use random.choice to select a random item from the output of
get_options().

Parameters:
- `context` (C, default None): Blender context. bpy.context if not provided.
- `update_ui` (bool, default False): Will also show the chosen item as the active thumbnail in the template_icon_view. Defaults to False.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/common_baseclasses/pcoll_content.py#L68

### get_options()

```python
BaseClothing.get_options(context: C = None, category: str = 'All') -> List[str]
```

*inherited from PreviewCollectionContent*

Get a list of options you can use for the set() method of this content.

These represent the choises the user sees in the UI. The output is a list of
relative paths to the content files, starting from the Human Generator folder.

Parameters:
- `context` (C, default None): Blender context. bpy.context if not provided.
- `category` (str, default 'All'): Category to filter the content by. Defaults to "All". You can get a list of categories from the get_categories() method.

Returns: List[str] — List[str]: List of relative paths to content files. You can pick one of these and pass it to the set() method.

Raises: ValueError — If the passed category is not present in the list of categories.

Raises: HumGenException — If no options can be found, this can be caused by the content pack for this type of content not being installed.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/common_baseclasses/pcoll_content.py#L98

### get_categories()

```python
BaseClothing.get_categories() -> list[str]
```

*inherited from PreviewCollectionContent*

Get a list of categoris this content type is organized in.

You can choose one of these categories to filter the content retreived from
get_options().

Returns: list[str] — list[str]: List of categories. These are the names of the folders the content is saved in.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/common_baseclasses/pcoll_content.py#L148

### refresh_pcoll()

```python
BaseClothing.refresh_pcoll(context: C = None, override_category: Optional[str] = None, ignore_searchterm: bool = False)
```

*inherited from PreviewCollectionContent*

Refresh the items of this preview collection.

This is low level functionality, you should not need to use this. It is used
to refresh the list of possible content for this human. If you use get_options()
this is automatically done for you.

Parameters:
- `context` (C, default None): Blender context. bpy.context if not provided.
- `override_category` (Optional[str], default None): Override the category to use, if not provided all items regardless of category will be shown.
- `ignore_searchterm` (bool, default False): If True, the searchterm set by the user will be ignored. Defaults to False.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/common_baseclasses/pcoll_content.py#L180

### save_objects_optimized()

```python
BaseClothing.save_objects_optimized(context: bpy.types.Context, objs: Iterable[bpy.types.Object], folder: str, filename: str, clear_sk: bool = True, clear_materials: bool = True, clear_vg: bool = True, clear_ps: bool = True, run_in_background: bool = True, clear_drivers: bool = True)
```

*static method, inherited from SavableContent*

Saves the passed objects as a new blend file.

opening the file in the background to make it as small as possible

Parameters:
- `context` (bpy.types.Context): Blender context.
- `objs` (Iterable[bpy.types.Object]): List of objects to save
- `folder` (str): Folder to save the file in
- `filename` (str): Name to save the file as
- `clear_sk` (bool, default True): Remove all shapekeys from objs. Defaults to True.
- `clear_materials` (bool, default True): Remove all materials from objs. Defaults to True.
- `clear_vg` (bool, default True): Remove all vertex groups from objs. Defaults to True.
- `clear_ps` (bool, default True): Remove all particle systems from objs. Defaults to True.
- `run_in_background` (bool, default True): Open the new subprocess in the background. Defaults to True.
- `clear_drivers` (bool, default True): Remove all drivers from objs. Defaults to True.

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/common_baseclasses/savable_content.py#L24

### remove_number_suffix()

```python
BaseClothing.remove_number_suffix(name: str) -> str
```

*static method, inherited from SavableContent*

Remove the number suffix from the passed name (i.e. Box.004 becomes Box).

Parameters:
- `name` (str): name to remove suffix from

Returns: str — name without suffix

Source: https://github.com/OliverJPost/HumGen3D/blob/main/human/common_baseclasses/savable_content.py#L152
