Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inserts in Paperspace

13 REPLIES 13
Reply
Message 1 of 14
wkmvrij
678 Views, 13 Replies

Inserts in Paperspace

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

13 REPLIES 13
Message 2 of 14
devitg
in reply to: wkmvrij

A dwg sample could help to help you 

Message 3 of 14
wkmvrij
in reply to: devitg

I hope this clears the question a bit...

Message 4 of 14
devitg
in reply to: wkmvrij

Some like it ??

 

open with XLS 

Message 5 of 14
wkmvrij
in reply to: devitg

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?

 

Message 6 of 14
hmsilva
in reply to: wkmvrij

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

EESignature

Message 7 of 14
pbejse
in reply to: hmsilva

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

Message 8 of 14
hmsilva
in reply to: pbejse

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... Smiley Embarassed

 

Nice code, pBe 🙂

 

Cheers
Henrique

EESignature

Message 9 of 14
devitg
in reply to: hmsilva

As the OP state to my post , he want what I show at the txt file 

Message 10 of 14
hmsilva
in reply to: devitg


@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

EESignature

Message 11 of 14
wkmvrij
in reply to: wkmvrij

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 Smiley Happy.

 

W.K.M. van Rij 

Message 12 of 14
pbejse
in reply to: wkmvrij


@wkmvrij wrote:

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 Smiley Happy.

 

W.K.M. van Rij 


Glad we could help wkmvrij. 

 

pBe

Message 13 of 14
pbejse
in reply to: hmsilva


@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... Smiley Embarassed

 

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  beer.gif

 

Message 14 of 14
hmsilva
in reply to: pbejse

Cheers pBe

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost