# 파라메트릭 컴포넌트 등록하기

파라메트릭 컴포넌트는 치수, 색상 등의 파라미터를 동적으로 조합할 수 있는 고급 컴포넌트입니다. 일반 컴포넌트와 달리 사용자가 아키스케치 에디터에서 파라미터 값을 직접 조정할 수 있습니다.

모든 API 요청 헤더에 `X-API-KEY`를 포함해야 합니다. 발급 방법은 [API 사용 방법](/dev/api.md)을 참고하세요.

```http
X-API-KEY: {x-api-key}
```

## 파라메트릭 컴포넌트 생성하기

**POST** `/api/v1/parametric`

{% stepper %}
{% step %}

### 필요한 정보 준비하기

파라메트릭 컴포넌트는 일반 컴포넌트 정보 외에 **파라미터 목록**과 **컴포지션 목록**이 필요합니다.

| 필드                 | 타입      |  필수 | 설명                                           |
| ------------------ | ------- | :-: | -------------------------------------------- |
| name               | string  |  ✅  | 이름                                           |
| parametricType     | string  |  ✅  | 파라메트릭 유형 (`assembly`, `parametric-modeling`) |
| translatedNames    | array   |  ✅  | 다국어 이름                                       |
| dimension          | object  |  ✅  | 치수                                           |
| parameters         | array   |  ✅  | 파라미터 목록                                      |
| compositions       | array   |  ✅  | 컴포지션 목록                                      |
| images             | array   |  ✅  | 이미지 URL 목록                                   |
| isFinal            | boolean |     | 최종 부품 여부 (에디터에서 직접 배치 가능 여부)                 |
| isPersonal         | boolean |     | 개인 라이브러리 여부                                  |
| modelingId         | string  |     | 모델링 ID                                       |
| parametricModeling | object  |     | 파라메트릭 모델링 (`parametric-modeling` 타입일 때 사용)   |
| editorSetting      | object  |     | 에디터 설정                                       |
| extra              | object  |     | 추가 정보 (boundingBox 등)                        |
| previewImage       | string  |     | 미리보기 이미지 URL                                 |
| code               | string  |     | 코드                                           |
| brandCode          | string  |     | 브랜드 코드                                       |
| sku                | string  |     | SKU                                          |
| color              | object  |     | 색상                                           |
| retailPrice        | object  |     | 소비자가                                         |
| factoryPrice       | object  |     | 공장가                                          |
| mainMaterial       | string  |     | 주재료                                          |
| glbUrl             | string  |     | GLB URL                                      |
| category           | object  |     | 카테고리                                         |
| {% endstep %}      |         |     |                                              |

{% step %}

### 요청 보내기

```json
POST /api/v1/parametric
X-API-KEY: {x-api-key}

{
  "name": "파라메트릭 소파",
  "parametricType": "assembly",
  "translatedNames": [
    { "code": "en", "value": "Parametric Sofa" },
    { "code": "ko", "value": "파라메트릭 소파" }
  ],
  "dimension": {
    "mm": { "width": 0, "depth": 0, "height": 0 }
  },
  "images": [],
  "isFinal": true,
  "editorSetting": {
    "editorType": "STANDING_ITEM",
    "dimensionLock": { "width": false, "depth": false, "height": false }
  },
  "parameters": [
    {
      "displayName": "Width",
      "referenceName": "W",
      "type": "BASIC",
      "valueInfo": {
        "usage": "NUMBER",
        "value": "900",
        "optionType": "RANGE",
        "options": { "min": "100", "max": "2400", "stepSize": "1" }
      },
      "priority": 0
    }
  ],
  "compositions": [],
  "parametricModeling": null
}
```

{% endstep %}

{% step %}

### 응답 확인하기

생성된 파라메트릭 컴포넌트의 ID를 저장해두세요. 이후 파라미터 추가·수정에 사용합니다.

```json
{
  "result": "SUCCESS",
  "data": {
    "componentId": "pmc_abc123"
  }
}
```

{% endstep %}
{% endstepper %}

## 파라메트릭 컴포넌트 수정하기

**PUT** `/api/v1/parametric/components/{id}`

생성과 동일한 Request Body 구조입니다.

| 파라미터 | 타입     |  필수 | 설명      |
| ---- | ------ | :-: | ------- |
| id   | string |  ✅  | 컴포넌트 ID |

## 파라미터 관리하기

### 파라미터 목록 조회

**GET** `/api/v1/parametric/components/{componentId}/parameters`

```http
GET /api/v1/parametric/components/pmc_abc123/parameters
X-API-KEY: {x-api-key}
```

### 파라미터 추가

**POST** `/api/v1/parametric/components/{componentId}/parameters`

| 필드         | 타입    |  필수 | 설명          |
| ---------- | ----- | :-: | ----------- |
| parameters | array |  ✅  | 생성할 파라미터 목록 |

### 파라미터 수정

**POST** `/api/v1/parametric/components/parameters/{parameterId}`

| 필드                    | 타입      |  필수 | 설명         |
| --------------------- | ------- | :-: | ---------- |
| displayName           | string  |  ✅  | 표시 이름      |
| referenceName         | string  |  ✅  | 참조 이름      |
| type                  | string  |  ✅  | 파라미터 타입    |
| valueInfo             | object  |  ✅  | 값 정보       |
| priority              | integer |  ✅  | 우선순위       |
| description           | string  |     | 설명         |
| hideCondition         | string  |     | 숨김 조건 표현식  |
| enterpriseParameterId | string  |     | 기업 파라미터 ID |

### 파라미터 단건 삭제

**DELETE** `/api/v1/parametric/components/parameters/{parameterId}`

### 파라미터 다건 삭제

**DELETE** `/api/v1/parametric/components/parameters`

| 필드           | 타입    |  필수 | 설명             |
| ------------ | ----- | :-: | -------------- |
| parameterIds | array |  ✅  | 삭제할 파라미터 ID 목록 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.archisketch.com/dev/api-2/3d-product-integration/parametric.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
