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

IpfcViewOwner

by ToolBOX01 2023. 1. 16.
반응형

■ IpfcViewOwner

모델에 저장된 보기(VIEW) 리스트들을 핸들링 할 수 있습니다.
logical screen coordinates (화면의 좌측 하단)기준으로 모델을 회전을 할수 있습니다. 

>> 기본 코드

Dim oSession As pfcls.IpfcBaseSession
Dim oViewOwner As IpfcViewOwner
Set oViewOwner = oSession.CurrentModel

■ IpfcViewOwner.CurrentViewRotate

- logical screen coordinates 의 X, Y 또는 Z축을 기준으로 현재 보기에서 모델을 회전 시킵니다.

EpfcCOORD_AXIS_X -> "0"
EpfcCOORD_AXIS_Y -> "1"
EpfcCOORD_AXIS_Z -> "2"

>> 코드

logical screen coordinates의 "x" 축 45도 회전 합니다

Dim oWindows As IpfcWindow: Set oWindows = oSession.CurrentWindow
Dim oViewOwner As IpfcViewOwner: Set oViewOwner = oSession.CurrentModel
    
Call oViewOwner.CurrentViewRotate(0, 45)
    
oWindows.Refresh

 

실행전 실행후

 

■ IpfcViewOwner.GetCurrentViewTransform

현재 보기에서 모델에 대한 변환을 검색합니다. 변환은 개체의 좌표계에서 논리적 화면 좌표의 거리 이루어집니다. 화면 좌표(Screen coordinates)는 일종의 nominal pixel 수이므로 기본 창의 왼쪽 아래 모서리는 (0, 0)이고 오른쪽 위 모서리는 (1000, 864)입니다. 화면 좌표는 일부 그래픽 기능, 마우스 입력 기능 및 그래픽을 그리거나 그림에서 항목을 조작하는 모든 기능에서 사용됩니다.

>> 코드

IpfcViewOwner.GetCurrentViewTransform는 변수 타입 "IpfcTransform3D"으로 반환 값을 받습니다.
IpfcTransform3D는 변수 타입 "IpfcPoint3D"으로 반환 값을 받습니다

IpfcPoint3D.GetOrigin은 좌표계의 원점을 나타내는 점을 검색합니다.

Dim oViewOwner As IpfcViewOwner
Set oViewOwner = oSession.CurrentModel
    
Dim oTransform3D As IpfcTransform3D
Set oTransform3D = oViewOwner.GetCurrentViewTransform
    
Dim oPoint3D As IpfcPoint3D
Set oPoint3D = oTransform3D.GetOrigin
    
Cells(1, "C") = oPoint3D.Item(0)
Cells(2, "C") = oPoint3D.Item(1)
Cells(3, "C") = oPoint3D.Item(2)

 

3D 모델 엑셀 - 프로그램 실행

 

■ IpfcViewOwner.SetCurrentViewTransform

현재 보기(screen 좌표계) 에서 모델의 좌표계로 위치로 변환을 설정합니다.
 - 화면 좌표  - > 모델 좌표로 변환입니다.

Dim oViewOwner As IpfcViewOwner: Set oViewOwner = oSession.CurrentModel
'// Model 좌표계     
Dim oCreateTransform3D As New CCpfcTransform3D
Dim oTransform3D As IpfcTransform3D
Dim oMatrix3D As New CpfcMatrix3D
Dim i, j As Integer

    For i = 0 To 3
        For j = 0 To 3
              If i = j Then
                  Call oMatrix3D.Set(i, j, 1#)
              Else
                  Call oMatrix3D.Set(i, j, 0#)
              End If
         Next j
    Next i
    
Set oTransform3D = oCreateTransform3D.Create(oMatrix3D)
Call oViewOwner.SetCurrentViewTransform(oTransform3D)
Call oViewOwner.CurrentViewRotate(0, 45#)

oMatrix3D.Set(0, 0, 1.0)
oMatrix3D.Set(0, 1, 0.0)
oMatrix3D.Set(0, 2, 0.0)
oMatrix3D.Set(0, 3, 0.0)
oMatrix3D.Set(1, 0, 0.0)
oMatrix3D.Set(1, 1, 1.0)
oMatrix3D.Set(1, 2, 0.0)
oMatrix3D.Set(1, 3, 0.0)
oMatrix3D.Set(2, 0, 0.0)
oMatrix3D.Set(2, 1, 0.0)
oMatrix3D.Set(2, 2, 1.0)
oMatrix3D.Set(2, 3, 0.0)
oMatrix3D.Set(3, 0, 0.0)
oMatrix3D.Set(3, 1, 0.0)
oMatrix3D.Set(3, 2, 0.0)
oMatrix3D.Set(3, 3, 1.0)

실행전 실행후 (X 축 45도 회전)

 

>> 참고 자료

 

 

Coordinate Systems and Transformations

Coordinate Systems : VB API 에서 액세스할 수 있는 Creo의 다양한 좌표계 있습니다. ■ Solid Coordinate System - 솔리드 좌표계는 Creo Parametric 솔리드 모델 의 형상을 설명하는 데 사용되는 3차원 데카르트 좌

tool-2020.tistory.com

왜 4x4 행렬을 사용 하는가?

 

 

2-1장 공간 상의 한 물체(Body)의 위치 및 방향의 표현

Q. 물체가 어디에 있는지 어떻게 표현할까? 여기 아래의 그림처럼 헬기를 바라보는 3명의 친구가 있습니다. 우린 지금 전화(머~얼리 있음)로 3명의 친구에게 헬기의 위치를 묻고 있는 중이라고 상

blog.stanroot.com

 

 

MicroStation VBA Rotations in 3D

Introduction MicroStation is a 3D design tool. It lets you model objects in a 3D space, and also works in 2D. Often, we want to model an object and then rotate it. In this article, we discuss rotation in 3D using a VBA Matrix3d. If you're interested in 2D

www.la-solutions.co.uk