What is the best way (assuming there is one) to move a block instance's attribute with respect to the block instance's insertion point?
Entmod on the attribute doesn't seem to work, nor did vla-move.
On one set of blocks instances I'll need to move the attributes east, and in another set I'll need to move them west, so redefining is not an option.
I've attached a simple drawing showing "before" and "after".
Solved! Go to Solution.
Solved by tom_brabant. Go to Solution.
I think I've got something that wil work with help from http://www.theswamp.org/index.php?topic=31674.5;wap2
(defun thing ()
(setq e (car (entsel " pick block ")))
(setq blockOb (vlax-ename->vla-object e)
attribSetVariant (vla-getAttributes blockOb)
)
(setq atref (car (gc:VariantToLispData attribSetVariant)));carring is just moving the first attribute, we will want to loop through (gc:VariantToLispData attribSetVariant)
(vla-move atref (vlax-3d-point (list -5.0 -5.0 -5.0)) (vlax-3d-point (list 0.0 0.0 0.0)));WORKS
)
;http://www.theswamp.org/index.php?topic=31674.5;wap2
(defun gc:VariantToLispData (var)
(cond
((= (type var) 'variant)
(gc:VariantToLispData (vlax-variant-value var)))
((= (type var) 'safearray)
(mapcar 'gc:VariantToLispData (vlax-safearray->list var))
)
(T var)
)
)
As a demo
(defun c:test (/ ATT OBJ P1 S1) (if (and (setq s1 (ssget "_+.:E:S" '((0 . "INSERT") (66 . 1)))) (setq p1 (getpoint "\nPick the new Att Insertion Point: ")) );; and (progn (setq obj (vlax-ename->vla-object (ssname s1 0)) att (nth 0 (vlax-invoke obj 'GetAttributes)) );; setq (vla-move att (vla-get-insertionpoint att) (vlax-3D-point p1)) );; progn );; if (princ) )
HTH
Henrique
@tom_brabant wrote:
Entmod on the attribute doesn't seem to work
FWIW, entmod is a viable method - here is an example:
(defun c:moveatt ( / att enx ins key ) (while (progn (setvar 'errno 0) (setq att (car (nentsel "\nSelect attribute: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null att) nil) ( (/= "ATTRIB" (cdr (assoc 0 (entget att)))) (princ "\nSelected object is not an attribute.") ) ) ) ) (if (and (= 'ename (type att)) (setq ins (getpoint "\nSpecify new insertion point: ")) (setq enx (entget att)) ) (progn (if (and (zerop (cdr (assoc 72 enx))) (zerop (cdr (assoc 74 enx))) ) (setq key 10) (setq key 11) ) (if (entmod (subst (cons key (trans ins 1 0)) (assoc key enx) enx)) (entupd att) ) ) ) (princ) )
Hello
I need a similar lisp to allow me to select multiple attributes and move them relative to each other in a nearby location.
Can you help me?
Thanks