x
This commit is contained in:
+17
-2
@@ -38,6 +38,7 @@ def verify_with_freecad(stp_path):
|
||||
import Part
|
||||
import Mesh
|
||||
import MeshPart
|
||||
import Import
|
||||
|
||||
print(f"\n{'='*70}")
|
||||
print(f"FreeCAD 验证")
|
||||
@@ -46,8 +47,22 @@ def verify_with_freecad(stp_path):
|
||||
# 创建新文档
|
||||
doc = FreeCAD.newDocument("Verification")
|
||||
|
||||
# 导入STP文件
|
||||
Part.insert(stp_path, "Verification")
|
||||
# 导入STP文件 - FreeCAD 0.21.2 兼容方式
|
||||
try:
|
||||
# 方法1: Import.insert (FreeCAD 0.21+)
|
||||
Import.insert(stp_path, doc.Name)
|
||||
except Exception as e1:
|
||||
print(f"Import.insert 失败: {e1}")
|
||||
try:
|
||||
# 方法2: Import.read
|
||||
objs = Import.read(stp_path)
|
||||
if objs:
|
||||
for obj in objs:
|
||||
doc.addObject(obj)
|
||||
except Exception as e2:
|
||||
print(f"Import.read 失败: {e2}")
|
||||
# 方法3: Part.insert (旧版本)
|
||||
Part.insert(stp_path, doc.Name)
|
||||
|
||||
# 获取所有形状对象
|
||||
shapes = []
|
||||
|
||||
Reference in New Issue
Block a user