Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/10/2019 in all areas

  1. You may wish to consider the following code: (defun c:c2xl ( / *error* col enx flg hed idx lst row sel typ xls xlsapp xlscls xlswbk xlswbs xlswsh ) (setq hed '("Rank" "Length" "Type")) ;; Column headings (defun *error* ( msg ) (if (and flg (= 'vla-object (type xlsapp))) (vl-catch-all-apply 'vlax-invoke-method (list xlsapp 'quit)) ) (foreach obj (list xlscls xlswsh xlswbk xlswbs xlsapp) (if (and (= 'vla-object (type obj)) (not (vlax-object-released-p obj))) (vlax-release-object obj) ) ) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) (princ (strcat "\nError: " msg)) ) (princ) ) (cond ( (not (and (setq sel (ssget '((0 . "ARC,CIRCLE")))) (setq xls (getfiled "Create Excel File" "" "xlsx;xls" 1)) ) ) ) ( (progn (repeat (setq idx (sslength sel)) (setq idx (1- idx) enx (entget (ssname sel idx)) typ (strcase (cdr (assoc 0 enx)) t) lst (cons (list (* (cdr (assoc 40 enx)) (if (= "circle" typ) (+ pi pi) (rem (+ pi pi (- (cdr (assoc 51 enx)) (cdr (assoc 50 enx)))) (+ pi pi)) ) ) typ ) lst ) ) ) (not (or (setq xlsapp (vlax-get-object "excel.application")) (and (setq xlsapp (vlax-create-object "excel.application")) (setq flg t) ) ) ) ) (princ "\nUnable to interface with Excel application.") ) ( t (setq xlswbs (vlax-get-property xlsapp 'workbooks) xlswbk (vlax-invoke-method xlswbs 'add) xlswsh (vlax-get-property xlswbk 'activesheet) xlscls (vlax-get-property xlswsh 'cells) ) (setq col 0) (foreach itm hed (vlax-put-property xlscls 'item 1 (setq col (1+ col)) itm) (vlax-put-property (vlax-get-property (vlax-variant-value (vlax-get-property xlscls 'item 1 col)) 'font ) 'bold :vlax-true ) ) (setq row 1) (foreach itm (vl-sort lst '(lambda ( a b ) (< (car a) (car b)))) (setq row (1+ row) col 0 ) (foreach val (cons (1- row) itm) (vlax-put-property xlscls 'item row (setq col (1+ col)) val) ) ) (if (and (< "11.0" (vlax-get-property xlsapp 'version)) (= (strcase (vl-filename-extension xls) t) ".xlsx") ) (vlax-invoke-method xlswbk 'saveas xls 51 "" "" :vlax-false :vlax-false 1 1) (vlax-invoke-method xlswbk 'saveas xls -4143 "" "" :vlax-false :vlax-false 1 1) ) (vlax-invoke-method xlswbk 'close :vlax-false) ) ) (*error* nil) (princ) ) (vl-load-com) (princ)
    1 point
  2. To cater for standard or dynamic blocks, you could the following Vanilla AutoLISP function, published on my site here: ;; Effective Block Name - Lee Mac ;; ent - [ent] Block Reference entity (defun LM:al-effectivename ( ent / blk rep ) (if (wcmatch (setq blk (cdr (assoc 2 (entget ent)))) "`**") (if (and (setq rep (cdadr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" blk) ) ) ) '("AcDbBlockRepBTag") ) ) ) ) (setq rep (handent (cdr (assoc 1005 rep)))) ) (setq blk (cdr (assoc 2 (entget rep)))) ) ) blk ) Call the above with a block reference entity name, e.g.: (if (and (setq e (car (entsel "\nSelect block: "))) (= "INSERT" (cdr (assoc 0 (entget e)))) ) (LM:al-effectivename e) )
    1 point
  3. Just for info... I solved findingclosestpointtofromblkref.lsp that works and for complex xrefs... You can find my latest code on theswamp site under link I provided... And yes I suggest using that last code as it is more reliable... M.R.
    1 point
  4. "; error: no function definition: vlax-get-acad-object" "; error: no function definition: vlax-ename->vla-object" If you find yourself receiving either of these errors, this is an indication that the ActiveX component of the Visual LISP API has not been loaded prior to running a program which relies on this function library. The Visual LISP ActiveX functions may be loaded using the (vl-load-com) function. This function need only be called once per session to ensure the functions are available throughout the drawing session, hence many users will have (vl-load-com) located at the top of their ACADDOC.lsp / ACAD.lsp customisation files so that the expression is automatically evaluated on startup. For this reason, a developer may not notice the omission of this function in their program. If you are receiving one of the above error messages when running a program, first try adding (vl-load-com) on a new-line at the top of the relevant LISP file. Example: Code without (vl-load-com): (defun c:test ( / ) (vlax-get-acad-object) (princ) ) Modified: (vl-load-com) (defun c:test ( / ) (vlax-get-acad-object) (princ) ) If you still receive either of the above errors after reloading the program equipped with (vl-load-com) consider performing a repair or reinstallation of your AutoCAD software, as the Visual LISP ActiveX component can occasionally become corrupted following the installation of an AutoCAD patch. If you are still stuck, search the forums or FAQ for more help.
    1 point
×
×
  • Create New...