Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catia V5 Macro Command Button and Text Box 2

Status
Not open for further replies.

makyy

Automotive
Mar 2, 2021
19
0
0
JP
Hello everyone,

I am working on the programming of Catia V5 macro but i must say i dont know a thing.

I think i have to perform a simple task but due to my lack of knowledge of Catia macro ,i am unable to do so.

The task is: to create a Command button and a text box area
So when i click the command button,a message should appear to select the view .(the view here is front view ,back view,etc. ,the one in drafting)
and when i select the view , the view nam should appear in the text box.(to notify me that i selected this view)

any help will be appreciated.
thankyou all in advance..
 
Replies continue below

Recommended for you

Background view cannot be selected directly. You have to build a custom selection dialog with VBA that would list all available views. Alternatively, a user can select main view (sheet itself) and then you would display a popup suggesting to click "Yes" to select main view or "No" to select background one.
 
I think by "back view" they may mean the projected rear view.

Anyway, I think you are looking for something like this.

build your userform, command button code:

Code:
Dim drawingDocument1 As Document
Set drawingDocument1 = CATIA.ActiveDocument

Dim InputObject(0)
InputObject(0) = "DrawingView"

Dim DrwSelect As Object
Set DrwSelect = CATIA.ActiveDocument.selection

Dim Status
Status = DrwSelect.SelectElement2(InputObject, "Select View", False)

Dim drwView
Set drwView = DrwSelect.Item(1).Value

ViewName.TextBox1.Text = (drwView.Name) '"ViewName" is the name of my userform
 
Thankyou so much for the code
But the later part of the code where the name of the view should appear in the text box doesnt work ..
The selection was done perfectly...
 
Thanks LucasC for the code.
I tried removing ViewName from the code and it worked perfectly.
{Before}
ViewName.TextBox1.Text = (drwView.Name) '"ViewName" is the name of my userform

{After}
TextBox1.Text = (drwView.Name) '"ViewName" is the name of my userform

Thanks a ton.
 
If anyone saw this forum, I have a part 2 of this forum. The query is different.
Can you please try and help me .
The title will be Catia V5 Macro Command Button and Text Box 2 of that query.
Thankyou everyone

Also、Can I select the multiple views and get their names in textbox..right now i can only get the name of one view.
 
Status
Not open for further replies.
Back
Top