bonjour je voulais remercier bryce avec beaucoup de retard(deplacement oblige) pour le lips qu'il a crée, qui fonctionne parfaitement et qui me sera tres utile. seul petit bemol mais peut etre trop complexe la possibilite de selectionner plusieurs attribut en même temps pour les deplacer suivant l' axe Z d'une valeur X ou Y donnée quel que soit leur altitude d'origine (defun c:MAJZ (/ obj acdoc precision *error* oldcmdecho blk b att ss ins)
; Met à jour pour toutes les références du bloc choisi un attribut sélectionné,
; pour y afficher la coordonnée Z du bloc.
; Brice Studer, mars 2011
;
;~~~~~~~ CONFIG ~~~~~~~~~~~
(setq precision 3) ; nombre de décimales de l'altitude
;~~~~~~~ FIN CONFIG ~~~~~~~
(vl-load-com)
(setq acdoc (vla-get-ActiveDocument (setq
obj (vlax-get-acad-object)))
)
;~~~~~~~ GESTION ERREURS ~~~~~~~~~~~
(defun *error* (msg)
(and msg
(or
(member (strcase msg) '("FUNCTION CANCELLED" "QUIT / EXIT ABORT" "FONCTION ANNULEE" "QUITTER / SORTIR ABANDON"))
(princ (strcat "\nErreur : " msg))
)
)
(if ss (vla-delete ss))
(setvar "cmdecho" oldcmdecho)
(vla-endundomark acdoc)
(princ)
)
;~~~~~~~ FIN GESTION ERREURS ~~~~~~~
;~~~~~~~ SOUS-FONCTIONS ~~~~~~~~~~~
(defun PutAttValue ( object tag value )
;; Lee Mac ~ 05.05.10
(mapcar
(function
(lambda ( attrib )
(and
(eq tag (vla-get-TagString attrib))
(vla-put-TextString attrib value)
)
)
)
(vlax-invoke object 'GetAttributes)
)
value
)
;~~~~~~~ FIN SOUS-FONCTIONS ~~~~~~~
(vla-StartUndoMark acdoc)
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(while
(not
(and
(setq blk (car (entsel "\nSélectionnez un des blocs à mettre à jour: ")))
(setq blk (vlax-ename->vla-object blk))
(= (vla-get-ObjectName blk) "AcDbBlockReference")
(setq blk (vla-get-effectivename blk))
);and
);not
(princ "\nL'objet sélectionné n'est pas un bloc ! ")
);while no bloc
(while
(not
(and
(setq att (car (nentsel "\nCliquez sur une valeur d'altitude: ")))
(setq att (vlax-ename->vla-object att))
(= (vla-get-ObjectName att) "AcDbAttribute")
(setq att (vla-get-tagstring att))
);and
);not
(princ "\nL'objet sélectionné n'est pas un attribut ! ")
);while no attribute
(if (ssget "_X" '( (0 . "INSERT") ) )
(vlax-for b (setq ss (vla-get-ActiveSelectionSet acdoc))
(if (= blk (vla-get-effectivename b))
(if
(and
(setq ins (vlax-get b 'InsertionPoint))
(setq ins (caddr ins))
)
(putattvalue b att (rtos ins 2 precision))
)
);if b = blk
);vlax-for
);if ssget
(*error* nil)
(princ)
);MAJZ
(princ "\nCommande à utiliser: MAJZ")
(princ)