반응형
□ Process of getting dimension
- Step 1 : IpfcModel2D
- Step 2 : IpfcView2D
- Step 3 : IpfcTransform3D
- Step 4 : IpfcBaseDimension
- Step 5 : IpfcDimension2D
This is a VBA program that gets the view name of a CREO PART drawing and the dimension ID included in the view.
- You can get dimension values and tolerance values.
- You can track changed dimension values and tolerance values.
- You can compare dimension values and tolerance values between drawings.
- You can analyze the dimension type of the drawing.
- You can automatically number the dimensions in front of the dimensions.
Main Code
Option Explicit
Sub Drawing02()
On Error GoTo RunError
'// Module Name : CreoVBAStart
Call CreoVBAStart.CreoConnt01
Dim GetModel As IpfcModel
Dim Model2D As IpfcModel2D
Dim Drawing As IpfcDrawing
Dim View2Ds As IpfcView2Ds
Dim View2D As IpfcView2D
Dim GetView2D As IpfcView2D
Dim Transform3D As IpfcTransform3D
Dim ViewOrigin As IpfcPoint3D
Dim BaseDimension As pfcls.IpfcBaseDimension
Dim Dimension2Ds As IpfcDimension2Ds
Dim Dimension2D As IpfcDimension2D
Dim i As Integer
Dim j As Integer
Dim lo As Integer
lo = 1
Set Model2D = BaseSession.CurrentModel
Set Drawing = Model2D
Set View2Ds = Model2D.List2DViews
For i = 0 To View2Ds.Count - 1
Set View2D = View2Ds.Item(i)
Set Transform3D = View2Ds.Item(i).GetTransform
Set ViewOrigin = Transform3D.GetOrigin
Worksheets("drawing01").Cells(i + 6, "A") = i + 1
Worksheets("drawing01").Cells(i + 6, "B") = View2D.Name
Worksheets("drawing01").Cells(i + 6, "C") = ViewOrigin.Item(0)
Worksheets("drawing01").Cells(i + 6, "D") = ViewOrigin.Item(1)
Worksheets("drawing01").Cells(i + 6, "E") = View2D.GetSheetNumber
Set GetModel = View2D.GetModel
Set Dimension2Ds = Model2D.ListShownDimensions(GetModel, EpfcModelItemType.EpfcITEM_DIMENSION)
For j = 0 To Dimension2Ds.Count - 1
Set BaseDimension = Dimension2Ds.Item(j)
Set Dimension2D = BaseDimension
Set GetView2D = Dimension2D.GetView
If GetView2D.Name = View2D.Name Then
Worksheets("drawing01").Cells(i + 6, "E").Offset(, lo) = BaseDimension.Symbol
lo = lo + 1
End If
Next j
lo = 1
Next i
MsgBox "I brought all the Drawing View names and Dimension IDs.", vbInformation, "korealionkk@gmail.com"
conn.Disconnect (2)
'// Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set BaseSession = Nothing
Set model = Nothing
RunError:
If Err.Number <> 0 Then
MsgBox "Process Failed: An error occurred." & vbCrLf & _
"Error No: " & CStr(Err.Number) & vbCrLf & _
"Error Description: " & Err.Description & vbCrLf & _
"Error Source: " & Err.Source, vbCritical, "Error"
If Not conn Is Nothing Then
If conn.IsRunning Then
conn.Disconnect (2)
End If
End If
End If
End Sub
★ Set Model2D = BaseSession.CurrentModel
Get the active drawing information
★ Set View2Ds = Model2D.List2DViews
Get view information for a drawing
★ Set GetModel = View2D.GetModel
To retrieve the dimension information stored in 3D, retrieve 3D information
★ Dimension2Ds = Model2D.ListShownDimensions(GetModel, EpfcModelItemType.EpfcITEM_DIMENSION)
Get 2D dimension information from 3D models
▷ Reference Code : Drawing Dimension All Display With Tolerence
▷ Reference
'VBA, VB.NET For Creo' 카테고리의 다른 글
VBA 서브 프로시저 (Sub Procedure) (0) | 2024.09.08 |
---|---|
Change Creo Model and Get Volume Values (Creo 9.0) (0) | 2024.09.07 |
Get Creo drawing view name and location values (4) | 2024.09.04 |
Get the character height value of drawing (0) | 2024.09.04 |
Get Creo File Names In Your Workfolder (0) | 2024.09.03 |