Hi all,
For context, I am trying to create electrical schematics where attributes of blocks can be copied onto select blocks that are intersecting them (as if they are connected on a schematic). The idea being that I can have a switchboard reference copied onto the circuit breaker connected to it.
I am trying to run FastSelect and nest in an attribute copy command within it. The problem is, I don't wish for user interaction - FastSelect requires user prompting and I also would like it to cycle through every named block instance so it automatically does it for the entire workspace.
I am using the following code for cycling through my blocks:
Code:
(vl-load-com)
(defun C:SELBLKN ( / e ss objs blk) ; by name
(setq e (getstring T "\nType block name(s) to select (comma-delimited list or wildcards): ")
objs (ssadd))
(if (setq ss (ssget "_X" '((0 . "INSERT"))))
(progn
(repeat (setq i (sslength ss))
(setq name (strcase (vla-get-effectivename (vlax-ename->vla-object (setq blk (ssname ss (setq i (1- i))))))))
(if (wcmatch name (strcase e))
(ssadd blk objs)))
(if (zerop (getvar "CMDACTIVE"))
(progn (sssetfirst nil objs)
(princ "Use 'P' for this selection set: ")(princ))
objs)))
)
(princ "\nSELBLKN commands loaded.")(princ)
And the following for copying attributes:
Code:
(defun c:CAttribTag ( / att tag str blk a )
(vl-load-com)
(setq att (nentsel "\nPick attribute..."))
(setq tag (vla-get-tagstring (vlax-ename->vla-object att)))
(setq str (vla-get-textstring (vlax-ename->vla-object att)))
(while (setq blk (car (entsel "\nPick block to paste attribute value to - ENTER TO FINISH...")))
(setq a blk)
(while (= (cdr (assoc 0 (entget (setq a (entnext a))))) "CABLEREF")
(if (= (strcase tag) (strcase (vla-get-tagstring (vlax-ename->vla-object a))))
(vla-put-textstring (vlax-ename->vla-object a) str)
)
)
)
(princ)
)
Understandably it is a hard ask, but is anyone able to assist me with combining these functionalities/able to point me in the right direction for easy fast-select integration?
Cheers for all of your help
Hugh