×
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

select an item and then launch a macro

select an item and then launch a macro

select an item and then launch a macro

(OP)
Hello everyone.
How can I get a macro to work with an item previously
clicked (in particular, I'm talking about a dimension in a
design)?
My problem is to find a command that can recognize an item if is highlighted or not and then use it in macro.
Thanks
 

RE: select an item and then launch a macro

in the macro get the selection object of the document. you might also want to use selectelement2 (single selection) or SelectElement3 (multiple selections) in the macro to allow users to select a dimension if on is not already selected

Read the API documentation for these calls. and be careful of earlybinding / strong typing the selection object if you are going to use any of the calls that require an array of variant strings.

Very roughly something like the following (not tested)

Dim oDoc
Dim oSel
Dim vaFilter(0)
Dim sRet
Dim oObject

Set oDoc = CATIA.activeDocument

Set oSel = oDoc.Selection

vaFilter(0) = "DrawingDimension" 'not sure if this is the correct type name for a dimension object

 sRet = oSel.SelectElement2(vaFilter,"Select Dimension", true) 'the true here allows preselection
if sRet = "Normal" then
  set oObject = oSel.item(1).value
else
  msgbox "Selection canceled"
end if  

RE: select an item and then launch a macro

(OP)
Thanks Peter your solution works very good!
Now i've another problem: i use this routine to create
labels(drawingtexts) associated to dimensions, and so i need create a similar routine for eliminate these texts.
The only way that i've found at the moment is to use
"drawingtexts.remove(0)" but is very difficult to use it coupled with the routine above.
Any idea?
Thanks  

RE: select an item and then launch a macro

oSel.delete will remove every thing in the selection

RE: select an item and then launch a macro

(OP)
Ouch!! i'm stupid!!
Thanks again Peter

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