Hallo joehz,
ja ich bin NC-Programmierer und befasse mich neben CATPart , CATProduct , CATDrawing eben auch mit CATProcess.
Anbei das Makro welches verwendet wird um einen Startprocess(.CATProcess) aus einem Vorlagenmenü zu wählen.
Nochmal die Schritte:
1.Product mit z.B. zwei Part ist geöffnet.
2.Makro start ( Quellcode siehe hier. Keine Ahnung ob der Code so korrekt ist aber er funktioniert für unsere Arbeitsweise :-) )
##############################################################################################################################################################
Sub CATMain()
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim processDocument1 As Document
On Error Resume Next
Set activedoc = CATIA.ActiveDocument
If Err.Number <> 0 Then
MsgBox "Es ist kein Dokument geöffnet Makro wird beendet", 16
Exit Sub
End If
If InStr(CATIA.ActiveDocument.Name, ".CATProduct") < 1 Then
MsgBox "Active CATIA Document ist kein Produkt. öffnen Sie ein Produkt und versuchen Sie es erneut.", , msgboxtext
Exit Sub
End If
' Name und Speicherort merken
X1 = CATIA.ActiveDocument.Product.PartNumber
X2 = CATIA.ActiveDocument.FullName
tstr = tstr & "*************************************************************" & vbCrLf
tstr = tstr & "Kurze Erklärung" & " !!! Bitte Lesen !!!" & vbCrLf
tstr = tstr & "*************************************************************" & vbCrLf & vbCrLf & vbCrLf
tstr = tstr & "1. Wichtig!! Das Produkt muss aktiv sein" & vbCrLf
tstr = tstr & "2. Alles muss gespeichert sein" & vbCrLf
tstr = tstr & "3. Es dürfen keine weiteren Catia Fenster geöffnet sein" & vbCrLf
tstr = tstr & "4. Sie können aus einer Startprocessvorlage wählen" & vbCrLf & vbCrLf
tstr = tstr & "Moechten Sie jetzt fortfahren?" & vbCrLf & vbCrLf
tstr = tstr & "JA = Fortfahren" & vbCrLf
tstr = tstr & "NEIN = Abbrechen" & vbCrLf
tint = MsgBox(tstr, vbYesNo, "Automatisierte Process Erstellung für die NC-Programmierung")
IF tint = VbNo then
Exit sub
end if
DasMenu = "Wähle eine Processvorlage durch Nummereingabe:" +Chr(10)+_
" "+Chr(10)+_
"1 = STARTPROZESSTEMPLATE_001" '+Chr(10)+Chr(10)+_
antwort = InputBox(DasMenu,"Auswahl:")
if isnumeric(antwort) then
If antwort = 1 then Set processDocument1 = documents1.NewFrom("\V5_NC_STARTPROCESS\0000-00-00_000-00__FRP_STARTPROZESSTEMPLATE_________________001_--____.CATProcess")
'If antwort = 2 then Set processDocument1 = documents1.NewFrom("\V5_NC_STARTPROCESS\0000-00-00_000-00__FRP_STARTPROZESSTEMPLATE_________________002_--____.CATProcess")
'If antwort = 3 then Set processDocument1 = documents1.NewFrom("\V5_NC_STARTPROCESS\0000-00-00_000-00__FRP_STARTPROZESSTEMPLATE_________________003_--____.CATProcess")
'If antwort = 4 then Set processDocument1 = documents1.NewFrom("\V5_NC_STARTPROCESS\0000-00-00_000-00__FRP_STARTPROZESSTEMPLATE_________________004_--____.CATProcess")
Bock = MsgBox("Wollen Sie den Process speichern?", vbYesNo + vbInformation)
If Bock = vbNo Then
Exit Sub
End if
Dim X2AB as String
Dim FISL as String
Dim X2NEU as String
X2AB = Mid(X2, 4, 25)
FiSL = Instr(X2AB, "\")
X2NEU = left(X2AB,FiSL-1)
'Speicherfile nochmal anzeigen
Myfile = InputBox("DL-Name zum speichern eingeben!" & Chr(10) & "Der DL-Name muss korrekt geschrieben sein, existieren und Sie müssen schreibrechte besitzen." & Chr(10) & "Geben sie nichts ein wird im V5_TRANSFER gespeichert.", "Speicherort", X2NEU, vbOK + vbInformation)
If Myfile = "" Then Myfile = "V5_TRANSFER"
'Dokument speichern unter
CATIA.ActiveDocument.SaveAs (Chr(1) & Chr(2) & "\" & Myfile & "\" & X1 & ".CATProcess")
'MsgBox "Der Process wurde erfolgreich gepeichert unter: "& Chr(10)& Chr(10) & Myfile & Chr(10)& Chr(10) & X1 & ".CATProcess"
end if
End Sub
#########################################################################################################################################################################
3. Nach dem Makrolauf ist ein Startprocess(.CATProcess) geöffnet. Jetzt will ich eben noch das das Produkt im CATProcess ausgetauscht wird.
Habe mal ein Makro aufzeichnen lassen folgendes wurde aufgezeichnet:
Language="VBSCRIPT"
Sub CATMain()
Dim processDocument1 As Document
Set processDocument1 = CATIA.ActiveDocument
Dim product1 As CATBaseDispatch
Set product1 = processDocument1.GetItem("PPRProduct")
Dim products1 As Products
Set products1 = product1.Products
Dim product2 As Product
Set product2 = products1.Item("Item.1")
Dim products2 As Products
Set products2 = product2.Products
Dim product3 As Product
Set product3 = products2.Item("0000-00-00_000-00__FRP_STARTPROZESSTEMPLATE_________________001_--____.1")
products2.Remove product3
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim partDocument1 As Document
Set partDocument1 = documents1.Item("0000-00-00_000-00__PRT_STARTPROZESSTEMPLATE_________________001_--____.CATPart")
Dim part1 As Part
Set part1 = partDocument1.Part
Dim partDocument2 As Document
Set partDocument2 = documents1.Item("NC_PART_1.CATPart")
Dim part2 As Part
Set part2 = partDocument2.Part
Dim partDocument3 As Document
Set partDocument3 = documents1.Item("NC_PART_2.CATPart")
Dim part3 As Part
Set part3 = partDocument3.Part
End Sub
Wenn ich das aufgezeichnete Makro starten will bekomm ich eine Fehlermeldung. Habe so ein Gefühl wie wenn das was ich wünsche nicht umsetzbar ist
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP