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!

Add components as MTD via macro

Status
Not open for further replies.

Manuel Pimenta

Mechanical
Aug 17, 2019
11
0
0
PT
Hello everyone,

At my company, we use MTD workbench to desing our products for two reasons: the drilling capabilities and the component insertion/edition menus.
Everyone is very used to it, and all our databases take great advantage of both features of MTD mentioned before.

I have developed a macro to insert components in specific places of an assembly, and it's working great.
When I shared it with my colleagues, their only complaint was that the components are not inserted as MTD (Mold Tooling Design) components.
In the macro, the components are inserted via "Insert existing component", so all the MTD commands are not available.
You can see the MTD commands I'm referring to in the image below.
1111_qstrwi.png


My answer to them was to create a toolbar with the commands.
22222_fikstu.png

The problem is that some of the commands do not work in components that are not inserted as MTD, namely "Add New Instance" and "Isolate Component", at least in the CATIA version we are currently running (V5 R28). Everyone uses this commands all the time, so I'm still hearing complaints.

The definitive solution to my problem would be to get the macro to insert components as MTD, but I haven't found a way to do it.
Does anyone know if it's possible to insert components as MTD via macro?
 
Replies continue below

Recommended for you

I'm not familiar with that workbench but try calling the MTD workbench in the code for those specific commands you want. I'm assuming it has its own version of "insert existing component"

Here's a bit of code to get the workbench ID and a command list

Code:
Sub CATMain()
'get the current workbench
Dim strCurWbench as String
strCurWbench = CATIA.GetWorkbenchID

MsgBox "The current Workbench is: " & strCurWbench & (Chr(10)) & (Chr(10)) & "Available internal commands for this workbench are listed in the next window." & (Chr(10)) & (Chr(10)) & "Select desired command and follow instructions in lower left corner of CATIA window."
'Chr(10) is used to go to a new line

'open the Commands List using the power input box
CATIA.StartCommand "Commands List"
'may have to change to CATIA.StartCommand "c:Commands List" or change your settings

End Sub

And an example of retrieving the workbench in your code.

Code:
Dim SPAWB As Workbench
    Set SPAWB = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
 
Status
Not open for further replies.
Back
Top