Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

How to return a clicked name?

Status
Not open for further replies.

kingmao

New member
Aug 13, 2007
7
If the name can be returned when I click a certain partbody or others with left-button of mouse?I don't know if VBA can do this work.

thank u
 
Replies continue below

Recommended for you

It is certainly possible to to have a macro that used selectelement2 to get and return the name of the body that was selected.

However is is not possible to have a macro that sits and watches for you to click on a body and then reports the name as this would require events and these are not available in catia automation with out a RADE license

Set oPartDoc = CATIA.ActiveDocument
'Get the part from the Document
Set oPart = oPartDoc.Part
'Get the selection object from the document
Set oSel = oPartDoc.Selection

'Add the name of items that are valid selections
vaValidSelections(0) = "Body"

'Clear the selection
oSel.Clear
'Prompt user to select a body
sStatus = oSel.SelectElement2(vaValidSelections, "Select the body to extract the geometry from", False)
If sStatus = "Normal" Then
set oBody = oSel.item(1).value
msgbox oBody.name
end if
 
Thank you,PeterGuy .
I think there is an alternative method to solve it.I can put a button on a form,your code can be put into click-event of button.This form run with catia synchronously.User can click the button after user select a certain body,then selectelement code is trigger to output the selected element.

what do u think about the method?
 
I personally would not bother with the form just make the macro and attach it to a button in CATIA (make your own toolbar if you want). Unless of course the for does other important stuff. Just be aware that you have to be careful of the status of your form when running SelectElement2 (ie. don't have a modal form and try SelectElement2) read the selection object documentation and the SelectElement2 method
 
PeterGuy ,could u please tell me the difference of IndicateOrSelectElement3D() and SelectElement2()?I think they has same function.
 
KingMao,

IndicateOrSelectElement3D and SelectElement2 have different functionality.

With Indicate..... you can specify a position in space in a 3d document window.

For example you could indicate that you want to select the vertex of a corner and then have CATIA build some geometry based on that indicated selection.

Regards

Neville
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor