January 3, 2015 at 10:18 pm #1447
I would like to ask if you know how to create macro codes for the following:
1. Generating screenshots from a list of catparts and saving it in a specific folder
2. Export all CATPART file names in an excel sheet once all files are saved in a folder
Thanks in advance
ToniJanuary 5, 2015 at 6:47 pm #1448
Welcome to the forum!
1. There is an article here that will give you an idea of how to create a screen shot macro: http://www.scripting4v5.com/additional-articles/screen-shot-macro/ If you have any specific questions about the code please let me know.
2. Are you exporting from CATIA to Excel, Excel to CATIA, or something else? Please explain more what you are trying to do. Also, there are example codes how to export in my book (http://www.scripting4v5.com/books/vb-scripting-for-catia-v5/) and macro pack: http://www.scripting4v5.com/books/catia-macro-pack-download/.
EmmettJanuary 5, 2015 at 9:19 pm #1449
thanks again for your nice reply.
The macro I want to create should do the steps described below
From a list of CAT Parts
1. Open a CATpart
2. Retrieve info from catpart (part number etc..)
3. Change viewpoint to iso and hide the specification tree.
4. Reframe part in window so that it is all visible.
5. Take picture and store it in required location with specific filename (probably the catpart filename and the current date / time and the fileextension for the picture type.)
6. Write info including hyperlink to open picture to an empty line in an excel file.
7. Close the catpart
8. Goto step 1.
Regarding step number 2 I didn’ t find info regarding this topic and also I dont know how to create the loop in order to save the list of images.
Thanks again and regards
PS: My current version is CATIA V5 R24January 6, 2015 at 9:33 pm #1451
as discussed , I started to retrieve information from a list of catparts,
using the code published in your book.
Now I would like to be able to run this script on every part and export the properties into the same Excel sheet. ( like I am showing in this code)
Any ideas how to add on to my code to accomplish this?
Remarks: The code opens the excel sheet but is not able to export the properties of the catparts.
Any ideas how to fix this issue?
Thanks and regards
Dim documents1 As Documents
Set documents1 = CATIA.Documents
MsgBox “The number of documents is ” & documents1.Count
Dim doc1 As String
Set doc1 = documents1.Item(1)
‘For Each doc1 in documents1
Dim partDoc1 as PartDocument
Set partDoc1 = doc1
Dim Excel As Object
Dim workbooks As workbooks
Dim workbook As workbook
Dim worksheet As Excel.worksheet
On Error Resume Next
Set Excel = GetObject(, “EXCEL.Application”)
If Err.Number <> 0 Then
Set Excel = CreateObject(“EXCEL.Application”)
MsgBox “Please note you have to close Excel”, vbCritical
Excel.Visible = True
‘load a sheet
Set workbooks = Excel.Application.workbooks
Set myworkbook = Excel.workbooks.Add
Set myworksheet = Excel.ActiveWorkbook.Add
Set myworksheet = Excel.Sheets.Add
‘download the properties
Excel.Cells(2, 2) = getThickness
Excel.Cells(2, 3) = getMaterial
Excel.Cells(2, 4) = getMass
End SubJanuary 15, 2015 at 6:15 pm #1502
You need to define what getThickness, getMeterial, etc. are. Try adding the below code after Dim partDoc1 as PartDocument:1234567891011Dim part1 as PartSet part1 = partDoc1.PartDim myParameters As ParametersSet myParameters = partDoc1.Product.UserRefPropertiesDim getThickness, getMaterial, getMass, nom, RealPartNumber As StringgetThickness = myParameters.Item(part1.Name & "\Properties\Thickness").ValueAsStringgetMaterial = myParameters.Item(part1.Name & "\Properties\Material").ValueAsStringgetMass = myParameters.Item(part1.Name & "\Properties\Mass").ValueAsString
The forum ‘CATIA Macro Programming’ is closed to new topics and replies.