반응형
■ 프로그램 화면
- 하드디스크에 있는 모델 파일을 불러 옵니다
- 모델 이름은 VBA Cell에 있습니다.
■ 프로그램 코드
Option Explicit
Sub componentAssy()
Application.EnableEvents = False
On Error GoTo RunError
Dim pathArray As New Collection
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim oSession As pfcls.IpfcBaseSession
Dim oModel As IpfcModel
Dim oSolid As IpfcSolid
Dim oAssembly As IpfcAssembly
Dim oAsmcomp As IpfcComponentFeat
Dim oCreoFileName As String
'// Session File Open
Dim oCreateModelDescriptor As New CCpfcModelDescriptor
Dim oModelDescriptor As IpfcModelDescriptor
Set conn = asynconn.Connect("", "", ".", 5)
Set oSession = conn.session
Set oModel = oSession.CurrentModel
oCreoFileName = Cells(8, "B")
Set oModelDescriptor = oCreateModelDescriptor.CreateFromFileName(oCreoFileName)
Set oSolid = oSession.RetrieveModel(oModelDescriptor) '// Session으로 모델 불러오기
Set oAssembly = oModel
Set oAsmcomp = oAssembly.AssembleComponent(oSolid, Nothing)
oAsmcomp.RedefineThroughUI
conn.Disconnect (2)
'Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set oSession = Nothing
Set oModel = Nothing
RunError:
If Err.Number <> 0 Then
MsgBox "Process Failed : Unknown error occurred." + Chr(13) + _
"Error No: " + CStr(Err.Number) + Chr(13) + _
"Error: " + Err.Description, vbCritical, "Error"
If Not conn Is Nothing Then
If conn.IsRunning Then
conn.Disconnect (2)
End If
End If
End If
End Sub
■ 프로그램 실행 화면
by lionkk@idt21c.com
'VBA, VB.NET For Creo' 카테고리의 다른 글
Family Table Part (1) | 2023.01.01 |
---|---|
라이브러리 관리 프로그램 #1 (0) | 2022.12.28 |
ToolBOX VBA 1.5 개발 작업 #4 (0) | 2022.12.27 |
Feature ID 및 Feature 이름 검색 프로그램 # 3/3 (0) | 2022.12.23 |
Parent-Child Relationships between the VB API Objects (0) | 2022.12.23 |