Hallo,
ich versuche gerade mit Hilfe eines Makros Allcatparts zu erstellen (
http://ww3.cad.de/foren/ubb/Forum137/HTML/005599.shtml). Dazu will ich die einzelnen AllCatParts in einem Ordner zwischenspeichern, leider bekomme ich aber eine Fehlermeldung wenn ich das Makro ein zweites Mal ausführen will (Teil noch im Speicher geladen?) dass die SaveAs Methode fehlgeschlagen ist. Manchmal wird trotzdem gespeichert manchmal auch nicht. Woran liegt das und wie kann ich das umgehen?
Ein weiteres Problem ist das erstellen und speichern eines neuen Products hier bekomme ich die gleiche Fehlermeldung.
Hier mal der noch etwas unschöne Code:
Code:
Language="VBSCRIPT"
Sub CATMain()
if Catia.FileSystem.folderexists("C:\Temp\Catia\AllCatPart") then
Catia.FileSystem.DeleteFolder ("C:\Temp\Catia\AllCatPart")
end if
if Catia.FileSystem.folderexists("C:\Temp\Catia\FertigesProduct") then
Catia.FileSystem.DeleteFolder ("C:\Temp\Catia\FertigesProduct")
end if
Catia.FileSystem.CreateFolder ("C:\Temp\Catia\AllCatPart\") 'Ordner erstellen
Catia.FileSystem.CreateFolder ("C:\Temp\Catia\FertigesProduct\")
Dim intDocObj 'Erstellen der AllCatParts
Dim intProdObj
Dim intProdsObj
Dim AllCatPartName
Dim Pfad
Dim documents1 As Documents
Dim productDocument1 As Document
Dim specsAndGeomWindow1 As Window
Dim viewer3D1 As Viewer
Dim viewpoint3D1 As Viewpoint3D
Dim products1 As Products
Set documents1 = CATIA.Documents
PrdouctName = Catia.ActiveDocument.Name
Set intDocObj = CATIA.ActiveDocument
Set intProdObj = intDocObj.Product
Set intProdsObj = intProdObj.Products
For i = 1 To intProdsObj.Count
If Typename (intProdsObj.Item (i).ReferenceProduct.Parent) = "ProductDocument" Then
Dim oProd2Part As DECProductToPart
Set oProd2Part = intProdsObj.Item (i).ReferenceProduct.GetItem("DECProductToPart")
oProd2Part.Run
sError = oProd2Part.GetError
Set oAllCATPart = oProd2Part.GetResult
Set partDocument1 = CATIA.ActiveDocument
AllCatPartName = partDocument1.Name
Pfad = "C:\Temp\Catia\AllCatPart\" & AllCatPartName
Catia.DisplayFileAlerts = False
partDocument1.SaveAs (Pfad)
partDocument1.Close
End If
Next
Set documents1 = CATIA.Documents
Set productDocument1 = documents1.Add("Product")
Set specsAndGeomWindow1 = CATIA.ActiveWindow
Set viewer3D1 = specsAndGeomWindow1.ActiveViewer
Set viewpoint3D1 = viewer3D1.Viewpoint3D
msgbox ProductName
productDocument1.SaveAs "C:\temp\Catia\FertigesProduct\" & ProductName
Set products1 = product1.ProductsDim arrayOfVariantOfBSTR1(0)
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\temp\Catia\AllCatPart"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
arrayOfVariantOfBSTR1(0) = "C:\temp\Catia\AllCatPart\QTR_AllCATPart.CATPart" & objFile.Name
products1.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All"
Next
'Catia.FileSystem.DeleteFolder ("C:\Temp\Catia\AllCatPart\")
End Sub
Danke schonmal im Voraus!
Gruß
Thomas
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP