반응형
▷ Reference
□ introduction
- Select and retrieve the Parameter name from the Cell.
- The selected parameters will be deleted.
- Save the model
▷ Code to select a cell and get parameter names
Option Explicit
Public selectcellname() As Variant
Public selectcellcount As Integer
Public Sub ShowSelectedCellValue()
Dim selectedCell As Range
Dim cell As Range
Dim i As Integer
Set selectedCell = Selection
selectcellcount = selectedCell.Count
'// Set array size to fit the number of selected cells
ReDim selectcellname(1 To selectedCell.Count)
'// If there are multiple values ??in the selected cell, each is displayed
If selectedCell.Count > 1 Then
i = 1
For Each cell In selectedCell
selectcellname(i) = cell.Value
i = i + 1
Next cell
Else
'// If the selected cell has only one value
ReDim selectcellname(1 To 1) '// Set array size to 1
selectcellname(1) = selectedCell.Value
End If
End Sub
▷ Main Code
Sub deleteparameter()
On Error GoTo RunError
'// Module Name : CreoVBAStart
Call CreoVBAStart.CreoConnt01
Call cellselete01.ShowSelectedCellValue
Dim ParameterOwner As pfcls.IpfcParameterOwner
Dim Parameter As IpfcParameter
Dim i As Integer
Set ParameterOwner = model
For i = 1 To selectcellcount
Set Parameter = ParameterOwner.GetParam(selectcellname(i))
Parameter.Delete
Next i
MsgBox "Delete Model Parameter Name", 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
Dim ErrorMessage As String
ErrorMessage = ErrorHandlerModule.MapErrorToMessage(Err.Number) '// Calling a function from a ErrorHandlerModule module
MsgBox "Process Failed: " & vbCrLf & _
"Error No: " & CStr(Err.Number) & vbCrLf & _
"Description: " & ErrorMessage, vbCritical, "Error"
If Not conn Is Nothing Then
If conn.IsRunning Then
conn.Disconnect (2)
End If
End If
End If
End Sub
You can get the parameter name that the model has.
You can remove unnecessary parameter names from the model.
You can create the parameter names you need.
You can import Creo models stored on your hard disk.
You can start and close Creo programs with VBA.
You can read over 100,000 Creo files and clean up unnecessary parameters.
Creo models contain a lot of design information. Design information is represented by parameters, annotations, dimensions, and holes. If the design information is stored accurately, machine learning is possible.
With CAD data in the cloud, machines will learn along with design information and images.
'VBA, VB.NET For Creo' 카테고리의 다른 글
Batch Convert DRW Files in a Colder to DWG (1) | 2024.10.02 |
---|---|
CREO VBA API 란? (2) | 2024.10.01 |
Get the Parameter name of the model and delete it (0) | 2024.09.14 |
How to set up and configure modules to use the VBA API (0) | 2024.09.11 |
Get the currently active model name (1) | 2024.09.09 |