count blocks & set lookup1
Hello lisp artists,need some help with these lisps, I want to automatically set the cable tags (block "kabeltype A or B") in the attached drawing.
The lisp should count the blocks in a range than set the lookup1 from the "kabeltype A or B" block.
Lisp "test1" counts the blocks in a range. (does not work well, counts more blocks).
Lisp "test2" set the "lookup1" table of selected block (block "kabeltype A or B") (this should go automatically).
All cabletags have the attribute "TEXT1" and have the value of the first value of a module (EIDS, ETV or I / O).
Can someone help me with these lisps, especially at the first (test1) for counting the blocks ...
(defun c:test1 ()(defun filter_set (blk tag lo hi / ss olst) (vl-load-com) (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 blk) (cons 66 1)))) (foreach blk (mapcar 'cadr (ssnamex ss)) (foreach att (vlax-invoke (vlax-ename->vla-object blk) 'getattributes) (and (eq tag (vla-get-tagstring att)) (not (vla-object (car en))) (setq dblist (vlax-invoke eo 'GetDynamicBlockProperties)) (foreach dbprop dblist (if (= (vla-get-PropertyName dbprop) "Lookup1") (vlax-put dbprop 'Value "8"))))
thanks in advance
PmxCAD
Opt1.dwg
Here's a quick one to get you started.
(defun c:foo (/ ss) (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(66 . 1)))) (foreach b (mapcar 'cadr (ssnamex ss)) (if (null (vl-some '(lambda (x) (= "TEXT1" (vla-get-tagstring x))) (vlax-invoke (vlax-ename->vla-object b) 'getattributes) ))(ssdel b ss) ) ) ) (sssetfirst nil ss) (princ)) ronjonp, Thanks for your anwser.
I'm not that good with lisp.I Can change it a bit and do some modifications.
As far as your lisp is concerned, it selects all the blocks with the tag TEXT1.
I'm not sure how I should apply it. I tried it in the existing lisp, but then the result remains the same, it counts all blocks (13) and yours lisp select everything.
PmxCAD dynamic blocks? -> get effective name My $0.05 which may not be right need a dwg to test.
(defun c:foo (/ ss)(setq count 0) (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "Sab-kast,U00009,U00017,U00028,U00039") '(66 . 1)))); count could be added into foreach (setq count (+ count 1))
is not necessary if dynamic blocks are not yet changed. you can select them as regular blocks. they are not yet Anonymous. Almost working,
Have a problem with the selection in "test3". Want to select the previous selection with entlast. I'm still playing around with the entsel or entlast. Do not get it working.
Does anyone have a suggestion?
(defun c:test1 (); Lee Mac(defun filter_set (blk tag lo hi / ss olst) (vl-load-com) (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 blk) (cons 66 1)))) (foreach blk (mapcar 'cadr (ssnamex ss)) (foreach att (vlax-invoke (vlax-ename->vla-object blk) 'getattributes) (and (eq tag (vla-get-tagstring att)) (not (
页:
[1]