Download presentation
Presentation is loading. Please wait.
Published byLaureen Little Modified over 8 years ago
1
How to: Simple User Interface WMCUG 13 th Jan 2010 Gord Vander Vliet Enterprise Tool & Die, LLC Jeff Roark Johnson Controls
2
Two Example CATIA VBA Form Excel Design Table
3
VBA Forms Pros No Links to maintain Executed from Macro No Synchronization Cons Used by CATIA expert VBA knowledge required Requires naming convention
4
Design Table Example Pros Does not require CATIA to change values Everyone knows Excel Cons Requires CATIA to update the model
5
VBA User Interface Create a Parametric Part Define Parameters required for the UI Create a VBA form
6
VBA User Interface Create a VBA Project Create New or Add an Existing catvba project
7
VBA User Interface Insert – UserForm Design the UI TextBox Buttons Coding – Module Run form the Macro function in CATIA Coding Load the UI
8
VBA User Interface View UI Code
9
VBA User Interface View UI Object
10
VBA User Interface Insert – Object resolution Select a CATIA Parameter to insert the needed VBA code
11
VBA User Interface Free VBA code!
12
VBA User Interface Add an “TextBox” Name it – Block_LengthTextBox
13
VBA User Interface Assign the Parameter value to the TextBox When the VBA UI is started it will get the Parameter Value from CATIA and assign the value to the TextBox in VBA UI. Should look like this. VBA has will provide popup dialog boxes to help you along the way
14
VBA User Interface Ready to Test the UI with CATIA Parameter value is assigned to the TextBox Next step is to be able to change the value from the TextBox and assign that value to the CATIA Parameter.
15
VBA User Interface Original Code -Remove the length1 form the Private Sub UserForm1 -Added length1 as a Public variable so it’ s value can be used in both Subs
16
VBA User Interface Ready to Test the UI with CATIA Parameter value is assigned to the TextBox Change the TextBox Value and Click the Button After the Part is updated the Parameter value shows the new value form the TextBox
17
VBA User Interface Sub CATMain() MsgBox "Hello CATIA Users" UserForm1.Show End Sub Final Example with copy/paste code Module1
18
VBA User Interface Public length1 As Length Private Sub enterBtn_Click() length1.ValuateFromString Block_LengthTextBox.Value Unload UserForm1 End Sub Private Sub UserForm_Activate() '---- Begin resolution script for object : Block_Length Dim partDocument1 As PartDocument Set partDocument1 = CATIA.ActiveDocument Dim part1 As Part Set part1 = partDocument1.Part Dim parameters1 As Parameters Set parameters1 = part1.Parameters Set length1 = parameters1.Item("Block_Length") Block_LengthTextBox.Value = length1.ValueAsString '---- End resolution script End Sub UserForm1
19
Excel UI Form
20
Create CATPart with required Parameters Create a Design Table Create a Excel VBA Form
21
Excel UI Form Double Click on the Design Table Click Edit Table Access the Excel File
22
Excel UI Form Make a Button
23
Excel UI Form Create a Macro – View Tab – Click Macro – Type a Name – Click Create
24
Excel UI Form Rt Click on the Button to assign it to a Macro
25
Excel UI Form Insert a Module Insert a UserForm
26
Excel UI Form Add the code in the Module to Show the Form UserForm1.Show will display the form when the macro is launched.
27
Excel UI Form Add the TextBox, Button, and Image
28
Excel UI Form Add a Background image Add Textbox and Button using the Toolbox
29
Excel UI Form Add this code to the UserForm
30
Excel UI Form When the form is Activated assign Cell values to TextBox
31
Excel UI Form Click the Enter Button to assign TexBox values to Cell
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.