Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

select an item and then launch a macro

Status
Not open for further replies.

vincio74

Automotive
Oct 11, 2010
9
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
 
Replies continue below

Recommended for you

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
 
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
 
oSel.delete will remove every thing in the selection
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor