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!

StartCommand Generate CATPart from Product and save the new file

Status
Not open for further replies.

gm2gabriel

Aerospace
Jul 23, 2020
4
BR
Hello, I would like to re-open the following thread:


I am writing a macro to be used in the "Assembly Design Workbench",at some point I would like to export/convert the selected .CATProduct to a .CATPart using the "Generate CATPart from Product..." command.

This could be done with the following code:

Sub GenerateCATPartFromProduct()
Dim ActDoc As ProductDocument
Set ActDoc = CATIA.ActiveDocument
Dim MySel As Selection
Set MySel = CATIA.ActiveDocument.Selection
MySel.Add ActDoc.Product '.Products.Item(1)
CATIA.RefreshDisplay = True
CATIA.StartCommand "Generate CATPart from Product..."
CATIA.RefreshDisplay = True
Dim PauseTime, Start, Finish, TotalTime
PauseTime = 0.5
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start
CATIA.RefreshDisplay = True
SendKeys "{Enter}", True
End Sub

Source:
CATIA Portable Script Center v2.0
GenerateCATPartFromProduct from gtwiki


The Sub works great, after it is finished a new window pops with the new converted part, however I need to automatically save and close this newly created part that will be used latter on. How could I do that?

If I put anything after the "SendKeys" line, for example a simple
MsgBox "Hello"

The SendKeys "Enter" stops working, as the Sub no longer pops the new windows, instead CATIA ends waiting for a "ENTER" at the "Generate CATPart From Product" window at the bottom right corner.

If possible, my goal is to "Generate CATPart From Product" with some "SaveAs" functionally, I mean: the user should not need to choose a new ParNumber for the part, or filename, or even see the new part in a new window, automatically saving the new part to a file is enoght.
 
Replies continue below

Recommended for you

Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top