@Anonymous wrote:
Hello. I've tried to use your code, but I am a beginner in lisp taks, so guess what ... I was not succesful. I am sending a simple block as example, so supposing that I want to insert it at coordinates x=100 and y=12, with the attribute NUMBER=01 and CODE=9887, how can I indicate these number in the lisp. I've tried to perform it using your example but I really do not have enough knolegment with autolisps to make it work. I think I am forgeting something. Could you please help me ?
Of course, we will help you jean_rossini
Keep in mind that this is a demonstration code,
(defun c:demo (/ _Insert&AddValue str p)
(defun _Insert&AddValue (bname p attvalue / blk)
(setq blk (vlax-invoke
(vlax-get
(vla-get-ActiveLayout
(vla-get-activedocument
(vlax-get-acad-object)))
'Block)
'InsertBlock p
bname 1 1 1 0))
(mapcar '(lambda (a b)
(vla-put-textstring a b))
(vlax-invoke blk 'Getattributes)
attvalue)
(princ)
)
(_Insert&AddValue
"dt" (list 100.00 12.00 0.0) (list "9887" "01"))
(princ)
)
If you are planning to use for real, it may look something like this
(defun c:demo2 (/ _Insert&AddValue str p)
(defun _Insert&AddValue (bname p attvalue / blk)
(setq blk (vlax-invoke
(vlax-get
(vla-get-ActiveLayout
(vla-get-activedocument
(vlax-get-acad-object)))
'Block)
'InsertBlock p
bname 1 1 1 0))
(mapcar '(lambda (a b)
(vla-put-textstring a b))
(vlax-invoke blk 'Getattributes)
attvalue)
(princ)
)
;;; DATA ;;;
(setq blockname "dt")
(setq pointsforinsertion '( (129.341 88.4354 0.0)
(109.854 115.512 0.0)
(75.4478 96.6498 0.0)
(71.1851 134.375 0.0)
(33.4296 95.1286 0.0)))
(setq code '("123" "75675" "687" "2345" "okidoki"))
(setq counter '("01""02" "03" "04" "05"))
;;; END of DATA ;;;
;;; Pass the value to _Insert&AddValue function ;;;
(mapcar '(lambda (x y z)
(_Insert&AddValue blockname x (list y z)))
pointsforinsertion
code
counter)
;;; END of function ;;;
(princ)
)
HTH