Hi from France
I need help about a dynamic block . I'm not at ease with the LISP
I created a dynamic block with a distance prop : "Distance1" + a visibility state "visibility1" + a flip state "flipstate1"
My block has 3 attributes tag "DISTANCE" , "VISIBILITY", "FLIPSTATE"
I want to put the value of these labels in the dynamic properties
I tried this LISP:
Code:;; gc:GetDynProps ;; Retourne la liste des propriétés dynamiques de la référence de bloc ;; sous la forme d'une liste de paire pointées (PropertyName . DynamicBlockProperty) ;; ;; Argument ;; bref : référence de bloc (vla-object) (defun gc:GetDynProps (bref / lst) (foreach p (vlax-invoke bref 'getDynamicBlockProperties) (setq lst (cons (cons (vla-get-PropertyName p) p) lst)) ) (reverse lst) ) ;; gc:GetAttributes ;; Retourne la liste des attributs de la référence de bloc ;; sous la forme d'une liste de paire pointées (TagString . AttributeReference) ;; ;; Argument ;; bref : référence de bloc (vla-object) (defun gc:GetAttributes (bref / lst) (foreach att (vlax-invoke bref 'GetAttributes) (setq lst (cons (cons (vla-get-TagString att) att) lst)) ) (reverse lst) ) ;; gc:AttToDynProp ;; Attribut à chaque propriété dynamique de la liste la valeur de l'attribut correspondante ;; ;; Arguments ;; bref : référence de bloc (vla-object) ;; lst : une liste de paires pointées (TagString . PropertyName) (defun gc:AttToDynProp (bref lst / atts props att prop) (setq atts (gc:GetAttributes bref) props (gc:GetDynProps bref) ) (foreach p lst (if (and (setq att (assoc (car p) atts)) (setq prop (assoc (cdr p) props)) ) (vl-catch-all-apply '(lambda (/ typ) (setq typ (vlax-variant-type (vla-get-Value (cdr prop)))) (cond ((< 1 typ 4) (vla-put-Value (cdr prop) (atoi (vla-get-TextString (cdr att)))) ) ((< 3 typ 6) (vla-put-Value (cdr prop) (atof (vla-get-TextString (cdr att)))) ) ((= 8 typ) (vla-put-Value (cdr prop) (vla-get-TextString (cdr att))) ) ) ) ) ) ) ) (defun c:majdyn (/ lst ss) (vl-load-com) (or *acad* (setq *acad* (vlax-get-acad-object))) (or *acdoc* (setq *acdoc* (vla-get-ActiveDocument *acad*))) (setq lst '( [surligneur]("DISTANCE" . "Distance1") ("ETATD'INVERSION" . "Etatd'inversion1") ("VISIBILITE" . "Visibilité1)[/surligneur] ) ) (if (ssget '((0 . "INSERT") (66 . 1))) (progn (vlax-for bref (setq ss (vla-get-ActiveSelectionSet *acdoc*)) (gc:AttToDynProp bref lst) ) (vla-Delete ss) ) ) (princ) )