본문 바로가기
  • Welcome!
VBA For Creo

IpfcModelItemOwner / IpfcModelItem / IpfcCoordSystem

by ToolBOX01 2022. 11. 23.
반응형

이것은 연관된 모델 항목(예: 모델)이 있는 개체의 기본 클래스입니다.

Function : GetItemById (Type as IpfcModelItemType, Id as Long) as IpfcModelItem [optional]
                  - 식별자(모델 타입)과 Feature ID가 지정된 지정된 모델 항목을 반환합니다.

1) IpfcModelItemType

EpfcITEM_FEATURE : Feature  / EpfcITEM_SURFACE : Surface / EpfcITEM_EDGE : Edge
EpfcITEM_COORD_SYS : Coordinate system / EpfcITEM_AXIS : Axis /EpfcITEM_POINT: Point
EpfcITEM_QUILT : Quilt / EpfcITEM_CURVE : Curve / EpfcITEM_LAYER : Layer
EpfcITEM_NOTE : A solid model note / EpfcITEM_DIMENSION : Dimension /
EpfcITEM_REF_DIMENSION : Reference dimension / EpfcITEM_SIMPREP : Simplified representation
EpfcITEM_SOLID_GEOMETRY : A solid geometry layer item. / EpfcITEM_TABLE : A drawing table
EpfcITEM_DTL_ENTITY : A detail entity / EpfcITEM_DTL_NOTE : A detail note
EpfcITEM_DTL_GROUP : A detail draft group / EpfcITEM_DTL_SYM_DEFINITION : A symbol definition
EpfcITEM_DTL_SYM_INSTANCE : A symbol instance / EpfcITEM_DTL_OLE_OBJECT : A drawing-embedded OLE object / EpfcITEM_EXPLODED_STATE : An exploded state / EpfcITEM_EDGE_START / EpfcITEM_LOG_EDGE
EpfcITEM_EDGE_END / EpfcITEM_XSEC : Cross Section / EpfcITEM_LAYER_STATE : Layer state
EpfcITEM_COMBINED_STATE : Combined state / EpfcITEM_STYLE_STATE : Style state
EpfcITEM_RP_MATERIAL : Material Item / EpfcITEM_VIEW : View / EpfcITEM_SURF_FIN 
EpfcITEM_ANNOT_PLANE / EpfcITEM_ANNOTATION_ELEM / EpfcITEM_SET_DATUM_TAG / EpfcITEM_GTOL
EpfcITEM_BODY : Solid body / EpfcITEM_CRV_START : Datum Curve End / EpfcITEM_CRV_END : Datum Curve End
EpfcModelItemType_nil : Use this enumerated value to represent "null" passed to optional properties or method arguments. 

2) ID

Feature ID 입니다.

[ Feature Name, Number, ID ]

 

Option Explicit
Sub cor()

    Dim asynconn As New pfcls.CCpfcAsyncConnection
    Dim conn As pfcls.IpfcAsyncConnection: Set conn = asynconn.CONNECT("", "", ".", 5)
    Dim oSession As IpfcBaseSession: Set oSession = conn.session
    Dim oModelItemOwner As IpfcModelItemOwner
    Set oModelItemOwner = oSession.CurrentModel
    
    Dim oModelItem As IpfcModelItem
    Set oModelItem = oModelItemOwner.GetItemById(EpfcITEM_FEATURE, 7)
    
    MsgBox oModelItem.GetName
    
    'Disconnect with Creo
    conn.Disconnect (2)
    
End Sub

 

Creo Model Tree VBA 실행 결과
[ Feature Name, Number, ID ]

 

Option Explicit
Sub cor()

    Dim asynconn As New pfcls.CCpfcAsyncConnection
    Dim conn As pfcls.IpfcAsyncConnection: Set conn = asynconn.CONNECT("", "", ".", 5)
    Dim oSession As IpfcBaseSession: Set oSession = conn.session
    Dim oModelItemOwner As IpfcModelItemOwner
    Set oModelItemOwner = oSession.CurrentModel
    
    Dim oModelItem As IpfcModelItem
    Set oModelItem = oModelItemOwner.GetItemByName(EpfcITEM_FEATURE, "PRT_CSYS_DEF")
    
    MsgBox oModelItem.ID
    
    'Disconnect with Creo
    conn.Disconnect (2)
    
End Sub

모델이 가지고 있는 Feature의 수량을 표시 합니다.

Option Explicit
Sub cor()

    Dim asynconn As New pfcls.CCpfcAsyncConnection
    Dim conn As pfcls.IpfcAsyncConnection: Set conn = asynconn.CONNECT("", "", ".", 5)
    Dim oSession As IpfcBaseSession: Set oSession = conn.session
    Dim oModelItemOwner As IpfcModelItemOwner
    Set oModelItemOwner = oSession.CurrentModel
    
    Dim oModelItems As IpfcModelItems
    Set oModelItems = oModelItemOwner.ListItems(EpfcITEM_FEATURE)
    
    MsgBox oModelItems.Count

    'Disconnect with Creo
    conn.Disconnect (2)
    
End Sub

'VBA For Creo' 카테고리의 다른 글

도면 자동 생성 기능  (0) 2022.11.30
의뢰] Part List 프로그램 변형 A01  (0) 2022.11.25
VBA Fundamentals #4 : IpfcSolid  (0) 2022.11.22
VBA Fundamentals #3 : IpfcModel  (0) 2022.11.20
VB로 만든 설계 자동화 프로그램  (0) 2022.11.18