MCPcopy Create free account
hub / github.com/VAST-AI-Research/tripo-python-sdk / mesh_segmentation

Method mesh_segmentation

tripo3d/client.py:1240–1289  ·  view source on GitHub ↗

Segment a 3D model. Args: original_model_task_id: The task ID of the original model. model_version: The model version to use. segmentation_granularity: Granularity for segment v2 (simple/balanced/detailed). ref_image: Local file path

(
        self,
        original_model_task_id: str,
        model_version: Optional[Literal["v1.0-20250506", "v2.0-20260430"]] = "v1.0-20250506",
        segmentation_granularity: Optional[str] = None,
        ref_image: Optional[str] = None,
        split_by_connectivity: Optional[bool] = None,
    )

Source from the content-addressed store, hash-verified

1238 return await self.create_task(task_data)
1239
1240 async def mesh_segmentation(
1241 self,
1242 original_model_task_id: str,
1243 model_version: Optional[Literal["v1.0-20250506", "v2.0-20260430"]] = "v1.0-20250506",
1244 segmentation_granularity: Optional[str] = None,
1245 ref_image: Optional[str] = None,
1246 split_by_connectivity: Optional[bool] = None,
1247 ) -> str:
1248 """
1249 Segment a 3D model.
1250
1251 Args:
1252 original_model_task_id: The task ID of the original model.
1253 model_version: The model version to use.
1254 segmentation_granularity: Granularity for segment v2 (simple/balanced/detailed).
1255 ref_image: Local file path or apiv3 file_<uuid> token (segment v2 only).
1256 split_by_connectivity: Whether to split by connectivity (segment v2 only).
1257 Returns:
1258 The task ID.
1259
1260 Raises:
1261 TripoRequestError: If the request fails.
1262 TripoAPIError: If the API returns an error.
1263 """
1264 if model_version == self.SEGMENT_V2_MODEL:
1265 body: Dict[str, Any] = {
1266 "type": "mesh_segmentation",
1267 "model": model_version,
1268 "input": original_model_task_id,
1269 }
1270 if segmentation_granularity:
1271 body["segmentation_granularity"] = segmentation_granularity
1272 if ref_image:
1273 if os.path.isfile(ref_image):
1274 ref_image = await self._v3_upload_file(ref_image)
1275 body["ref_image"] = ref_image
1276 if split_by_connectivity is not None:
1277 body["split_by_connectivity"] = split_by_connectivity
1278 response = await self._v3_request("POST", "/v3/mesh/segment", json_data=body)
1279 return response["data"]["task_id"]
1280
1281 task_data = {
1282 "type": "mesh_segmentation",
1283 "original_model_task_id": original_model_task_id,
1284 }
1285
1286 # Add optional parameters that were explicitly passed
1287 self._add_optional_params(task_data, passed_args=self._get_passed_args())
1288
1289 return await self.create_task(task_data)
1290
1291 async def mesh_completion(
1292 self,

Calls 5

_v3_upload_fileMethod · 0.95
_v3_requestMethod · 0.95
_add_optional_paramsMethod · 0.95
_get_passed_argsMethod · 0.95
create_taskMethod · 0.95