You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为PyMeshLab的mls_projection_apss指定当前网格为control和proxy mesh

解决方法

你可以直接接收ms.current_mesh_id()返回的当前网格ID,将其作为参数传入mls_projection_apss的controlmesh和proxymesh字段即可,修改后的代码如下:

import os
import pymeshlab

# 你的inputdir、outputdir_2定义部分保持不变
ms = pymeshlab.MeshSet()

for filename in os.listdir(inputdir):
    if filename.endswith(".stl"):
        ms.load_new_mesh(os.path.join(inputdir, filename))
        print(filename)
        # 接收当前网格ID
        current_mid = ms.current_mesh_id()
        print(current_mid)
        ms.remeshing_isotropic_explicit_remeshing(targetlen=0.1, checksurfdist=True, maxsurfdist=0.1)
        # 传入当前网格ID作为两个参数的取值
        ms.mls_projection_apss(controlmesh=current_mid, proxymesh=current_mid, filterscale=2)
        ms.save_current_mesh(os.path.join(outputdir_2, filename))
        # 处理完成后清空MeshSet,避免网格堆积占用内存,不需要保留历史网格可保留该行
        ms.clear()

如果你的业务场景需要保留所有加载过的网格不需要清空,去掉ms.clear()即可,每轮新加载的网格ID会自动递增,current_mesh_id()会返回最新加载的网格ID,传入参数后不会再默认调用ID为0的首个网格。

内容的提问来源于stack exchange,提问作者justone

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 15:18:03