Trang chủ
Giới thiệu
Tìm kiếm
1
Automation Studio 5.0 Full Crack
179 lượt xem
2
Harris's shock and vibration handbook
41 lượt xem
3
Các lệnh cad cơ bản cho người mới bắt đầu
24 lượt xem
4
Autodesk Autocad 2007 Full Crack
22 lượt xem
5
Một số lệnh thiết lập khung tên
22 lượt xem
Tài liệu học thuật
Phần mềm kỹ thuật
App script
Autodesk
Office
Matlab
Modelica
Đăng nhập
Tìm kiếm
Từ khóa tìm kiếm
autocad
inventor
ilogic
autolisp
mô phỏng
vba
cad/cam
model 3d
nosine
Đăng nhập
-
Đăng ký
Có
12
bài viết
Có
0
bình luận
Trang chủ
Danh mục
Tài liệu học thuật
Phần mềm kỹ thuật
App script
Autodesk
Office
Matlab
Modelica
Trang
Giới thiệu
Autodesk
(
6
bài viết)
2025-07-25
iLogic xuất tệp step hàng loạt
Chạy ổn định trên Inventor 2022PHIÊN BẢN 1Dim rootFolder As String = ThisDoc.Path Dim stepFolder As String = rootFolder & "\_step" ' Tạo thư mục nếu chưa tồn tại If Not System.IO.Directory.Exists(stepFolder) Then System.IO.Directory.CreateDirectory(stepFolder) End If ' Lấy danh sách file .ipt và .iam Dim files = System.IO.Directory.GetFiles(rootFolder, "*.ipt") files = files.Concat(System.IO.Directory.GetFiles(rootFolder, "*.iam")).ToArray() ' Thiết lập tùy chọn STEP Dim ctx As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext() oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oSTEP As TranslatorAddIn Dim i As Integer For i = 1 To ThisApplication.ApplicationAddIns.Count If ThisApplication.ApplicationAddIns.Item(i).ClassIdString = "{90AF7F40-0C01-11D5-8E83-0010B541CD80}" Then oSTEP = ThisApplication.ApplicationAddIns.Item(i) Exit For End If Next If oSTEP Is Nothing Then MessageBox.Show("Không tìm thấy STEP Translator.", "Lỗi") Return End If If Not oSTEP.Activated Then oSTEP.Activate() ' Lặp qua từng file và xuất ra STEP For Each filePath In files Try Dim doc As Document = ThisApplication.Documents.Open(filePath, False) Dim docName As String = System.IO.Path.GetFileNameWithoutExtension(filePath) Dim outputFile As String = stepFolder & "\" & docName & ".stp" Dim oData As DataMedium = ThisApplication.TransientObjects.CreateDataMedium() oData.FileName = outputFile oSTEP.SaveCopyAs(doc, oContext, oOptions, oData) doc.Close(True) Catch ex As Exception MessageBox.Show("Lỗi với file: " & filePath & vbCrLf & ex.Message, "Lỗi") End Try Next MessageBox.Show("Xuất STEP hoàn tất!", "Thành công")PHIÊN BẢN 2AddReference "System.Windows.Forms" Imports System.Windows.Forms Imports System.IO ' Chỉ xử lý file .ipt và .iam trong thư mục gốc, không duyệt thư mục con ' Không đóng mô hình hiện tại sau khi xuất ' Tạo danh sách tùy chọn Dim options As New ArrayList options.Add("Xuất tất cả các mô hình trong Project đang mở") options.Add("Xuất tất cả các mô hình trong thư mục được chọn") ' Hiển thị hộp thoại chọn tùy chọn Dim selectedOption = InputListBox("Chọn tùy chọn xuất file", options, options(0), "Xuất mô hình sang định dạng STEP", "Danh sách") ' Nếu hủy thì thoát If selectedOption = "" Then Return ' Xác định thư mục gốc dựa trên tùy chọn Dim rootFolder As String If selectedOption = options(0) Then rootFolder = ThisApplication.FileLocations.Workspace Else Dim folderDialog As New FolderBrowserDialog() folderDialog.Description = "Chọn thư mục chứa các mô hình" folderDialog.ShowNewFolderButton = False If folderDialog.ShowDialog() = DialogResult.OK Then rootFolder = folderDialog.SelectedPath Else Return End If End If ' Chọn thư mục đích lưu trữ Dim stepFolder As String Dim destFolderDialog As New FolderBrowserDialog() destFolderDialog.Description = "Chọn thư mục đích lưu trữ file STEP" destFolderDialog.ShowNewFolderButton = True If destFolderDialog.ShowDialog() = DialogResult.OK Then stepFolder = destFolderDialog.SelectedPath Else Return End If ' Tạo thư mục đích nếu chưa tồn tại If Not Directory.Exists(stepFolder) Then Directory.CreateDirectory(stepFolder) End If ' Lấy danh sách file .ipt và .iam chỉ trong thư mục gốc (không duyệt thư mục con) Dim iptFiles = Directory.EnumerateFiles(rootFolder, "*.ipt", SearchOption.TopDirectoryOnly) Dim iamFiles = Directory.EnumerateFiles(rootFolder, "*.iam", SearchOption.TopDirectoryOnly) Dim files = iptFiles.Concat(iamFiles).ToArray() ' Thiết lập tùy chọn STEP Dim ctx As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext() oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oSTEP As TranslatorAddIn Dim i As Integer For i = 1 To ThisApplication.ApplicationAddIns.Count If ThisApplication.ApplicationAddIns.Item(i).ClassIdString = "{90AF7F40-0C01-11D5-8E83-0010B541CD80}" Then oSTEP = ThisApplication.ApplicationAddIns.Item(i) Exit For End If Next If oSTEP Is Nothing Then MessageBox.Show("Không tìm thấy STEP Translator.", "Lỗi") Return End If If Not oSTEP.Activated Then oSTEP.Activate() ' Lấy tài liệu hiện tại Dim activeDoc As Document = ThisDoc.Document ' Lặp qua từng file và xuất ra STEP For Each filePath In files Try Dim doc As Document = ThisApplication.Documents.Open(filePath, False) ' Lấy tên file không có phần mở rộng Dim docName As String = System.IO.Path.GetFileNameWithoutExtension(filePath) Dim outputFile As String = stepFolder & "\" & docName & ".stp" Dim oData As DataMedium = ThisApplication.TransientObjects.CreateDataMedium() oData.FileName = outputFile oSTEP.SaveCopyAs(doc, oContext, oOptions, oData) ' Chỉ đóng tài liệu nếu không phải là tài liệu hiện tại If Not doc Is activeDoc Then doc.Close(True) End If Catch ex As Exception MessageBox.Show("Lỗi với file: " & filePath & vbCrLf & ex.Message, "Lỗi") End Try Next MessageBox.Show("Xuất STEP hoàn tất!", "Thành công")
25-07-2025
6
0
0
1
2