(vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Open ExcelFile$) (setq *ExcelApp% (vlax-get-or-create-object "Excel.Application")) (if (setq *ExcelApp% (vlax-get-object "Excel.Application")) (alert (strcat "Excel file " ExcelFile$ " not found.")) (setq (append (list Row# (1+ CreateLists: ((= (type ExcelValue) 'STR) (vl-string-trim " " ExcelValue)) ((= (type ExcelValue) 'REAL) (rtosr ExcelValue)) ((= (type ExcelValue) 'INT) (itoa ExcelValue)) (setq ExcelValue (vlax-variant-value ExcelVariant^)) (setq ExcelVariant^ (vlax-get-property ExcelRange^ 'Value)) (setq ExcelRange^ (vlax-get-property *ExcelApp% "Range" Range$)) (setq Range$ (strcat (Number2Alpha Column#)(itoa Row#))) (setq MaxColumn# (vlax-get-property (vlax-get-property CurRegion "Columns") "Count")) (setq MaxRow# (vlax-get-property (vlax-get-property CurRegion "Rows") "Count")) (vlax-get-property *ExcelApp% "ActiveSheet") "Range" "A1") "CurrentRegion") (setq MaxColumn# (nth 0 MaxRow# (nth 1 CurRegion (vlax-get-property (vlax-get-property (vlax-invoke-method Worksheet "Activate") (if (= (vlax-get-property Worksheet "Name") Sheet_Name$) (vlax-for Worksheet (vlax-get-property *ExcelApp% "Sheets") (defun CreateLists: (Sheet_Name$ Max_Range$ / Sheet_Name$ CreateLists: - Creates Lists of SheetName$ up to MaxRange$ of Excel data (defun GetExcel (ExcelFile$ SheetName$ MaxRange$ / Cnt# Column# CreateLists:ĬurRegion ExcelRange^ ExcelValue ExcelVariant^ Max_Range$ MaxColumn# MaxRow# Routine from Getexcel: Credit Terry Miller (defun c:MyPricing () What Attribute ID names found and the count is the variable that changes for each drawing.
(Ex: ID “A006” goes in row 10).ī) I can make a Putcell command ready for each of those ID names to cover all (1 through 200).Ĭ) How to associate block ID name with a row.ĭ) How to find duplicate block count and associate it with block ID name/row.Į) How to add ID name and count to a putcell command associated by row like this: (PutCell "B10" '("A006" 3)). Anyone know?)Ī) I have a set number of attribute ID names (1 through 200) that I will ever encounter so I know all the possible names and the rows it need to go to. Cant figure out how to attach a CAD file or excel file here. Here is a mockup image of the end result when blocks with IDs “A002”, “A006”, “A009”, “A012” are found in the attached drawing. I can have a putcell command with a row for all 200 ID names. Create a loop (foreach?) to add ID name and count into corresponding “Putcell” commands (know by its row number).Load the GetExcel.lsp functions needed to put info from CAD into existing Excel.These are the Steps I believe are needed in my routine: I think I have most of the separate parts needed but can’t figure out how to put it all together so looking for some help. I’m creating a pricing sheet by pulling attribute IDs and their duplicate block count (block instances) from a CAD drawing and putting them into an existing excel file.