Hi.
I Just wanna to add one function.
I want to use not the default block name "MyBlock" BUT a block name that I enter.
Please Help Me!
;;; Quick Block
;;; Tharwat 11. May. 2012 ;;
;;; http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/quick-block/td-p/3454228
;;; Modified by HasanCAD and Grrr1337 (in theswamp)
;;; https://www.theswamp.org/index.php?topic=52634.0
(defun c:B (/ selectionset insertionpoint number Blockname mn mx pnts)
(vl-load-com)
(defun LM:ssboundingbox ( sel / idx llp ls1 ls2 obj urp ) ; Lee mac
(repeat (setq idx (sslength sel))
(setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))
(if (and (vlax-method-applicable-p obj 'getboundingbox)
(not (vl-catch-all-error-p
(vl-catch-all-apply 'vla-getboundingbox (list obj 'llp 'urp)))))
(setq ls1 (cons (vlax-safearray->list llp) ls1)
ls2 (cons (vlax-safearray->list urp) ls2))))
(if (and ls1 ls2)
(mapcar '(lambda ( a b ) (apply 'mapcar (cons a b))) '(min max) (list ls1 ls2))))
(if (setq selectionset (ssget "_:L-I"))
(progn
(setq number 1
Blockname (strcat "MyBlock" (itoa number))
)
(while (tblsearch "BLOCK" Blockname)
(setq Blockname
(strcat "MyBlock" (itoa (setq number (1+ number))))
)
)
(or ; why? - select XLINE/RAY/POINT entity
(setq insertionpoint (getpoint "\n Specify insertion point <Press any key for Center>: "))
(and
(setq insertionpoint (LM:ssboundingbox selectionset))
(setq insertionpoint (apply 'mapcar (cons '(lambda (a b) (/ (+ a b) 2.)) insertionpoint))) ; thanks for this, Lee Mac
)
(setq insertionpoint (getpoint "\nYou must specify an insertion point <exit>: "))
); or
(command "_.-Block" Blockname insertionpoint selectionset "")
(command "_.-insert" Blockname insertionpoint "" "" "")
)
(princ)
)
(princ)
)