Hello guys! I am pretty new to TheSwamp - I've read many posts in last years but this is my first time posting, hehe.
Let me explain a situation: I actually use a .lisp script that export all the blocks (just like the BCOUNT command, but exporting onto a .csv file). The problem is that: everytime I need to open this .csv file and copy data inside the OLE Object (Excel Sheet) inside my .dwg drawing.
Is there a way to export it directly from .lisp code to the OLE object?
(defun c:lista_blocos (/ _doc nm ds b ly f lst fl op)
(vlax-for l (vla-get-layouts
(setq _doc
(vla-get-ActiveDocument (vlax-get-acad-object))))
(vlax-for o (vla-get-block l)
(if (and (eq (vla-get-objectname o) "AcDbBlockReference")
(setq nm (vla-get-effectivename o))
(setq ds
(if (vlax-property-available-p
(setq b (vla-item (vla-get-blocks _doc) nm))
'comments)
(vla-get-comments b)
"")
)
(setq ly (vla-get-layer o))
)
(if (vl-some '(lambda (x)
(and (eq ly (car x))
(eq nm (cadr x))
(setq f x)
)
)
lst)
(setq lst (subst (list ly nm (1+ (caddr f)) ds) f lst))
(setq lst (cons (list ly nm 1 ds) lst))
)
)
)
)
(setq lst (vl-sort lst '(lambda (j k) (< (car j) (car k)))))
(cond ((not lst)
(alert "Esse desenho não tem blocos!"))
((and (setq fl (getfiled "Selecione outro desenho"
(getvar 'DWGPREFIX)
"csv"
1))
(setq op (open fl "w"))
)
(write-line "Layer Name:;Block Name:;QTY;Description" op)
(mapcar '(lambda (x)
(write-line
(strcat (car x)
";"
(cadr x)
";"
(itoa (caddr x))
";"
(nth 3 x))
op))
lst)
(close op)
)
)
(princ)
)(vl-load-com)