This commit is contained in:
user 2024-12-10 15:52:11 +03:00
parent a2f01cd15f
commit fb0cf56db6
4 changed files with 22 additions and 10 deletions

View File

@ -74,6 +74,14 @@
"detail": "math", "detail": "math",
"documentation": {} "documentation": {}
}, },
{
"label": "k_constants",
"importPath": "project_support",
"description": "project_support",
"isExtraImport": true,
"detail": "project_support",
"documentation": {}
},
{ {
"label": "api5_module", "label": "api5_module",
"kind": 5, "kind": 5,

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,8 @@
import pythoncom import pythoncom
from win32com.client import Dispatch, gencache from win32com.client import Dispatch, gencache
import os import os
import math import math
from project_support import k_constants
# Получи API интерфейсов версии 5 # Получи API интерфейсов версии 5
api5_module = gencache.EnsureModule("{0422828C-F174-495E-AC5D-D31014DBBE87}", 0, 1, 0) api5_module = gencache.EnsureModule("{0422828C-F174-495E-AC5D-D31014DBBE87}", 0, 1, 0)
@ -38,7 +39,11 @@ try:
doc_components.append(element) doc_components.append(element)
else: else:
all_elements(element) all_elements(element)
all_elements(doc_3d.TopPart)
if doc_type == k_constants.ksDocumentAssembly:
all_elements(doc_3d.TopPart)
else:
doc_components.append(doc_3d.TopPart)
for component in doc_components: for component in doc_components:
component_ipart = module.IPart7(component) component_ipart = module.IPart7(component)
@ -82,15 +87,14 @@ try:
print(f"save to {doc_path}{saving_path}{filename}.cdw") print(f"save to {doc_path}{saving_path}{filename}.cdw")
c_doc.SaveAs(f"{doc_path}{saving_path}{filename}.cdw") c_doc.SaveAs(f"{doc_path}{saving_path}{filename}.cdw")
spec = application.Documents.Add(k_constants.ksDocumentSpecification) if doc_type == k_constants.ksDocumentAssembly:
spec_doc = module.ISpecificationDocument(spec) spec = application.Documents.Add(k_constants.ksDocumentSpecification)
spec_doc.AttachedDocuments.Add(doc.PathName, True) spec_doc = module.ISpecificationDocument(spec)
filename = 'Список_деталей' spec_doc.AttachedDocuments.Add(doc.PathName, True)
print(f"save to {doc_path}{saving_path}{filename}.spw") filename = 'Список_деталей'
spec.SaveAs(f"{doc_path}{saving_path}{filename}.spw") print(f"save to {doc_path}{saving_path}{filename}.spw")
spec.SaveAs(f"{doc_path}{saving_path}{filename}.spw")
# print(doc_name)
input('Нажмите Enter для дальнейшей работы') input('Нажмите Enter для дальнейшей работы')
except Exception as e: except Exception as e:
print(f"error with {i}") print(f"error with {i}")