StartCommand and SaveAs
StartCommand and SaveAs
(OP)
Hello,
I'm trying to write a macro to do "Generate CATPart from Product" then save the new part:
****
current_prod.Selection.Add current_prod.Product '
CATIA.StartCommand "Generate CATPart from Product"
CATIA.RefreshDisplay = True
For i = 1 To 100
SendKeys "{DELETE}"
Next i
SendKeys "NewPartName"
SendKeys "{ENTER}"
Sleep (7000) ' already declared : Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
CATIA.ActiveDocument.SaveAs current_prod.Path & "\NewCatPart"
****
As result , I have :
current_prod was saved in : current_prod.Path & "\NewCatPart"
the window "Generate CATPart from Product" displayed.
If i delete the two last lines of code, the generation works :(
Any help please ?
I'm trying to write a macro to do "Generate CATPart from Product" then save the new part:
****
current_prod.Selection.Add current_prod.Product '
CATIA.StartCommand "Generate CATPart from Product"
CATIA.RefreshDisplay = True
For i = 1 To 100
SendKeys "{DELETE}"
Next i
SendKeys "NewPartName"
SendKeys "{ENTER}"
Sleep (7000) ' already declared : Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
CATIA.ActiveDocument.SaveAs current_prod.Path & "\NewCatPart"
****
As result , I have :
current_prod was saved in : current_prod.Path & "\NewCatPart"
the window "Generate CATPart from Product" displayed.
If i delete the two last lines of code, the generation works :(
Any help please ?





RE: StartCommand and SaveAs
You need to create a new part, and them give it a partnumber and save it, Right?
CODE --> vba
Sub CATMain() Dim documents1 As Documents Set documents1 = CATIA.Documents Dim partDocument1 As PartDocument Set partDocument1 = documents1.Add("Part") Dim product1 As Product Set product1 = partDocument1.GetItem("Part1") Dim strFilePath As String strFilePath = CATIA.FileSelectionBox("Select the location to save the file, and insert it's part number", "*.CATPart", CatFileSelectionModeSave) Dim char As Integer char = Len(strFilePath) Dim C As String Dim D As String Dim i As Integer Do Until D = "\" i = i + 1 C = Right(strFilePath, i) D = Left(C, 1) Loop Dim PN As String PN = Right(strFilePath, i - 1) PN = Replace(PN, ".CATPart", "") product1.PartNumber = PN partDocument1.SaveAs strFilePath End SubSo try this, for the new part. Later you can try to add the bodies from the several parts to this one.
Tiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...
RE: StartCommand and SaveAs
I'am trying to save a part generated by the command "Generate CATPart from Product" .
Any help please ?
RE: StartCommand and SaveAs
What you really want to do?
Please recreate the needed steps.
Tiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...
RE: StartCommand and SaveAs
Google win API getwindow function, this is the entry point. From there you will have to search more.
As this is not a real CATIA topic I wont say more here, check https://stackoverflow.com/ and other net resources...
indocti discant et ament meminisse periti
RE: StartCommand and SaveAs
CODE --> VBA
Set oProductDocument = CATIA.ActiveDocument Set oProduct = oProductDocument.Product Set oProd2Part = oProduct.GetItem("DECProductToPart") oProd2Part.Run sError = oProd2Part.GetError Set oAllCATPart = oProd2Part.GetResult--Doug