after studying this code ive come to somewhat of an understanding (or more like assumptions)-
So the function is called C:HML (How Many Layouts) with arguments 'totalLayouts' 'dwgFiles' 'obdx' and 'layoutOndwgFile'
>with the first (And ) command, we get the directory that contains the project's dwg files "folder" and create a lists of all the dwg files "dwgFiles" of the poject.
> if the autocad version is earlier than version 16, we have to first set obdx to "ObjectDBX.AxDbDocument", "ACADVER"
> for each element in the 'dwgFiles' list, we ;
> first verify wether there is any errors while calling the individual files,
> then we return the value of the layout count for the files, and set this as 'LayoutOndwgFile'
> then insert this value in the first element of the list 'totalLayouts'
> repeat for all files in 'dwgFiles' and therefore, 'totalLayouts' will be a list containing all the Layout counts of each file
> print the value (integer to array) the sum of all the elements of "totalLayouts' (?)
few questions :
1) i dont understand this if loop in the setq command ;
(setq folder (acet-ui-pickdir (if folder folder (getvar 'dwgprefix))))
so you set a variable folder, by first determining if the not-yet-defined variable folder has the dwgprefix?
2) in (setq dwgFiles (vl-directory-files folder ".dwg" 1)) , what is the 1 for?
3)why do we have to add the ACADVER if the AutoCAD version is earlier than 16? i assume it has to do with the format but idk
4) in line 31;
(setq totalLayouts (cons (list itm ( 1- LayoutOndwgFile )) totalLayouts))
a) itm is item? as in an element in a list?
b) you used a decrement of 1 in the LayoutOndwgFile - is this because the model is counted as a layout and therefore has to be substracted?
c) again question about the syntax : you set 'totalLayouts' as a list of itself ( which in the first loop, should not have been defined yet) - is this because, it is a foreach loop and therefore, in the first iteration where it has not been defined yet, it will return as an empty list? and we fill it from there with the foreach loop?
5) in the line 41 ;
(print.....(itoa (apply '+ (mapcar 'cadr totalLayouts))
i thoght cadr returns the second element of the list TotalLayouts? i dont understand this line of code