x
This commit is contained in:
+17
-2
@@ -38,6 +38,7 @@ def verify_with_freecad(stp_path):
|
|||||||
import Part
|
import Part
|
||||||
import Mesh
|
import Mesh
|
||||||
import MeshPart
|
import MeshPart
|
||||||
|
import Import
|
||||||
|
|
||||||
print(f"\n{'='*70}")
|
print(f"\n{'='*70}")
|
||||||
print(f"FreeCAD 验证")
|
print(f"FreeCAD 验证")
|
||||||
@@ -46,8 +47,22 @@ def verify_with_freecad(stp_path):
|
|||||||
# 创建新文档
|
# 创建新文档
|
||||||
doc = FreeCAD.newDocument("Verification")
|
doc = FreeCAD.newDocument("Verification")
|
||||||
|
|
||||||
# 导入STP文件
|
# 导入STP文件 - FreeCAD 0.21.2 兼容方式
|
||||||
Part.insert(stp_path, "Verification")
|
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 = []
|
shapes = []
|
||||||
|
|||||||
Reference in New Issue
Block a user