Message 1 of 4
Insert specific block at a POSITION parameter in another block
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all!
I need a LISP command to automatically insert a "Position number" block at a point called "POSDATA" in my conveyor block. I tried using the following LISP, but it just doesn't work:
(defun c:POS (/ valid_blocks f ss i e data dpp len)
;;(setq valid_blocks '("CONV-480-B190""));;
(setq f (lambda (p) (vlax-get e p)))
(if
(setq ss (ssget '((0 . "INSERT")(2 . "`*U*,CONV-*"))))
(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (Setq i (1- i)))))
(setq data (mapcar 'f '("Insertionpoint" "Rotation" "EffectiveName" "XScaleFactor")))
(if (and
;;(member (caddr data) valid_blocks)
(vl-string-search "CONV-" (caddr data))
(setq dpp (mapcar '(lambda (e) (mapcar 'f
'("PropertyName" "Value" )))
(vlax-invoke e 'GetDynamicBlockProperties)))
(> (setq len (cadr (Assoc "Posdata" dpp))) 0)
)
(vlax-invoke
(vlax-get (vla-get-ActiveLayout
(vla-get-activedocument
(vlax-get-acad-object)
)
)
'Block
)
'InsertBlock
(polar (car data)
(+ (if (minusp (last data)) pi 0.0) (Cadr data))
len)
"POSITION2" ;; block needs to be in drawing to execute command
1 1 1 0) ;; <-- block rotation 0
)
)
)
(princ)
)
I don't have any experience in coding at all, so I don't know what to do other than replacing names and values in the code. Just for info, the conveyor blocks might vary in name, but they all start with "CONV-", eg.:
CONV-480-B180
CONV-580-B380
CONV-680-B90
and so on...
Attached example drawing with the conveyor block and the position block, and a description of what it is supposed to look like.
If any questions, I'll be glad to elaborate 🙂 thanks in advance