Good morning to each and all.
In a drawing with multiple layouts defined there is a (title)block inserted with attributes to be read out to an external Database. How do I approach these inserts and attributes in its own layout context in VLISP? So far I only manage to locate 1 insert whereas there are more defined. 😞
Wllem K.M. van Rij
Indeed this is what I am after! More in particular the link with the name of the layout. So how do I get there in VLISP?
As a demo...
(vlax-for layout (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (vlax-for block (vla-get-block layout) (if (and (= (vla-get-objectname block) "AcDbBlockReference") (= (vla-get-hasattributes block) :vlax-true) );; and (setq lst (cons (list (vla-get-name layout) (vla-get-name block)) lst)) );; if );; vlax-for );; vlax-for
HTH
Henrique
Building on Henriques post
(defun c:LO2CSV (/ aDoc blocks data bllst write2 openfile) (defun _promplist (bname blkcoll / prmpt lst) (vlax-for itm blkcoll (if (eq (vla-get-objectname itm) "AcDbAttributeDefinition") (setq prmpt (cons (vla-get-PromptString itm) prmpt)) ) ) (list bname (reverse prmpt)) ) (setq aDoc (vla-get-activedocument (vlax-get-acad-object)) blocks (vla-get-blocks aDoc) data nil ) (and (= (getvar 'dwgtitled) 1) (vlax-for layout (vla-get-layouts aDoc) (vlax-for block (vla-get-block layout) (if (and (= (vla-get-objectname block) "AcDbBlockReference") (= (vla-get-hasattributes block) :vlax-true) (member (Strcase (setq bn (vla-get-name block))) '("BOMBLOCK" "AMW_TITLE")) ) ;; and (progn (if (not (assoc bn bllst)) (setq prompts (_promplist bn (vla-item blocks bn)) bllst (cons prompts bllst) ) ) (setq data (cons (list (vla-get-name layout) bn (mapcar '(lambda (x y) (strcat x "\t" (Vla-get-textstring y)) ) (cadr (assoc bn bllst)) (vlax-invoke block 'GetAttributes) ) ) data ) ) ) ) ) data ) (setq write2 (strcat (getvar 'Dwgprefix) (vl-filename-base (getvar 'dwgname)) ".txt" ) ) (setq openfile (open write2 "w")) (setq data (vl-sort data '(lambda (a b) (< (car a) (car b))))) (Foreach itm data (princ (strcat "\n" (Car itm)) openfile) (princ (strcat "\n\t" (cadr itm)) openfile) (foreach info (caddr itm) (princ (strcat "\n\t\t" info) openfile) ) (princ) ) (not (close openfile)) (startapp "notepad" write2) ) (princ) )
HTH
The OP has written:
"...How do I approach these inserts and attributes in its own layout context in VLISP?..."
"...More in particular the link with the name of the layout. So how do I get there in VLISP?"
So, I understood that the OP only needed to find a way to link the blocks with the layouts...
Nice code, pBe 🙂
Cheers
Henrique
@devitg wrote:
As the OP state to my post , he want what I show at the txt file
Gabriel,
the OP state to your post:
"Indeed this is what I am after! More in particular the link with the name of the layout. So how do I get there in VLISP? "
"En efecto esto es lo que busco! Más en particular, el vínculo con el nombre de lo Layout. Entonces, ¿cómo puedo llegar en VLISP?"
My Spanish is rusty, but I think I did a fair translation.
You are correct, but I'm also correct
So I did provided a way to "link the INSERT with the name of the layout..."
Cheers
Henrique
Through this I would like to thank the above gentlemen for their suggestions with the help of which I have been able to complete the assigment .
W.K.M. van Rij
@hmsilva wrote:
The OP has written:
"...How do I approach these inserts and attributes in its own layout context in VLISP?..."
"...More in particular the link with the name of the layout. So how do I get there in VLISP?"
So, I understood that the OP only needed to find a way to link the blocks with the layouts...
Nice code, pBe 🙂
Cheers
Henrique
Thank you Henrique, You are too kind. Only picked-up where you left off is all. it was your idea really 🙂
Cheers