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

#8 IpfcBaseSession - 파일 Create Function

by ToolBOX01 2023. 8. 12.
반응형

■ Create Function 소개

비어 있는 part, 어셈블 파일을 생성 합니다. Template Drawing을 이용하여 새로운 도면을 새성 합니다. 타 CAD 데이터를 import 합니다.

  • IpfcBaseSession.CreateAssembly
  • IpfcBaseSession.CreateDrawingFromTemplate
  • IpfcBaseSession.CreateModelWindow
  • IpfcBaseSession.CreatePart

IpfcBaseSession.CreateAssembly

[Function] CreateAssembly (Name as String) as IpfcAssembly

사용 예)

Dim Window As IpfcWindow
Dim Assembly As IpfcAssembly

'//Session에 새로운 파일 생성 
Set Assembly = session.CreateAssembly("korea01")

Dim ModelDescriptorCreate As New CCpfcModelDescriptor
Dim ModelDescriptor As IpfcModelDescriptor

'//Session에 생성돤 새로운 파일 Open
Set ModelDescriptor = ModelDescriptorCreate.Create(EpfcMDL_ASSEMBLY, "korea01", Null)
Set model = session.RetrieveModel(ModelDescriptor)
Set Window = session.OpenFile(ModelDescriptor)
                          
Window.Activate

 

▷ IpfcBaseSession.CreateModelWindow

[Function] CreateModelWindow (Mdl as IpfcModel) as IpfcWindow

 

지정된 모델 (step,iges)에 대한 창을 만들거나 검색합니다. 즉 타 CAD 파일 포맷을 가져오는 코드 입니다.

 ["Mdl as IpfcModel" 관련 참고 자료] . . . 

 

 

VBA Excel - ImportNewModel

Hi, I'm working on an Excel VBA tool that imports a lot of pvz files into Creo and saves them as .asm's. Works like a charm when I do this by hand (obviously, these are not real CAD models but facet geometry). If I run the code below, I get a Type Mismatch

community.ptc.com

 

 ["Mdl as IpfcModel" 샘플 코드] . . . 

Dim mdl As IpfcModel = session.ImportNewModel("D:\WorkDir\Example\heatSink.step",
    _EpfcNewModelImportType.EpfcIMPORT_NEW_STEP,EpfcModelType.EpfcMDL_PART,"MyNewPart",
    _Nothing)
mdl.Display()

 

▷ IpfcBaseSession.CreateDrawingFromTemplate

Drawing Template 파일을 이용하여 드로잉 파일을 생성 합니다.

[Function] CreateDrawingFromTemplate (Name as String, Template as String, DrawingModel as IpfcModelDescriptor, Options as IpfcDrawingCreateOptions) as IpfcDrawing


Name : The new drawing name.
Template : The template drawing name. This should be located in the search path or the system template directory.
DrawingModel : The name and type of the solid model to use while populating template views.
Options : Sequence of options to use while creating the drawing.

 

Options 코드

Dim DrawingCreateOptions As IpfcDrawingCreateOptions
         
Call DrawingCreateOptions.Insert(0, EpfcDrawingCreateOption.EpfcDRAWINGCREATE_DISPLAY_DRAWING)
Call DrawingCreateOptions.Insert(0, EpfcDrawingCreateOption.EpfcDRAWINGCREATE_SHOW_ERROR_DIALOG)

 


 영업 문의 : lionkk@idt21c.com