×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to return a clicked name?

How to return a clicked name?

How to return a clicked name?

(OP)
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

RE: How to return a clicked name?

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

RE: How to return a clicked name?

(OP)
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?

RE: How to return a clicked name?

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

RE: How to return a clicked name?

(OP)
PeterGuy ,could u please tell me the difference of IndicateOrSelectElement3D() and SelectElement2()?I think they has same function.

RE: How to return a clicked name?

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

RE: How to return a clicked name?

(OP)
thank u nev99!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources