기능 : 매개변수 읽고, 쓰기
1) 재생성 2) SAVE 3) SAVE AS 기능은 없습니다.
새로 고침 버튼 클릭
Sub box_model()
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession
Dim Model As pfcls.IpfcModel
Set conn = asynconn.Connect("", "", ".", 5)
Set session = conn.session
Set Model = session.CurrentModel
Range("H5").Value = Model.Filename
Dim Powner As pfcls.IpfcParameterOwner
Dim param As IpfcBaseParameter
Dim ParamValue As IpfcParamValue
Dim WIDTH As Double, HEIGHT As Double, LENGTH As Double
Dim WIDTH_value As Double, height_value As Double, length_value As Double
Set Powner = Model
'Read Parameter WIDTH value
Set param = Powner.GetParam("WIDTH")
Set ParamValue = param.Value
WIDTH_value = ParamValue.DoubleValue
Cells(7, 8) = WIDTH_value
'Read Parameter HEIGHT value
Set param = Powner.GetParam("HEIGHT")
Set ParamValue = param.Value
height_value = ParamValue.DoubleValue
Cells(10, 8) = height_value
'Read Parameter LENGTH value
Set param = Powner.GetParam("LENGTH")
Set ParamValue = param.Value
length_value = ParamValue.DoubleValue
Cells(13, 8) = length_value
'Disconnect with Creo
conn.Disconnect (2)
'Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set session = Nothing
Set Model = Nothing
End Sub
가로 버튼 Source
Sub input_width()
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession
Dim Model As pfcls.IpfcModel
Dim WIDTH_filename As String
Set conn = asynconn.Connect("", "", ".", 5)
Set session = conn.session
Set Model = session.CurrentModel
Dim paramOwner As pfcls.IpfcParameterOwner
Dim WidthParam As pfcls.IpfcBaseParameter
Dim p1 As IpfcParameter
Dim ParamObject As New CMpfcModelItem
Dim ParamValue As pfcls.IpfcParamValue
Dim WIDTH_value As Double
Dim p2 As String
p2 = "width"
Range("H7").Select
WIDTH_value = ActiveCell.Value
Set paramOwner = Model
Set p1 = paramOwner.GetParam(p2)
Set WidthParam = p1
Set ParamValue = ParamObject.CreateDoubleParamValue(CDbl(WIDTH_value))
WidthParam.Value = ParamValue
'Disconnect with Creo
conn.Disconnect (2)
'Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set session = Nothing
Set Model = Nothing
End Sub
'VBA For Creo' 카테고리의 다른 글
VB API Fundamentals -- VBA 예제 (3) PART-LIST (0) | 2020.12.14 |
---|---|
4-2 # Parameter : Part 파일의 모든 매개변수, Type, Value 표시 하기 (0) | 2020.12.11 |
4-3 # Parameter : PART_NO 매개 변수 값 불러오기 (0) | 2020.12.09 |
Part list - 작업 중 (0) | 2020.12.09 |
예제 코드) 활성화된 Session 파일 명 모델 타입 표시하기 (0) | 2020.12.06 |