Print all the blocks in different sheets

Print all the blocks in different sheets

sarahFCCM2
Explorer Explorer
930 Views
5 Replies
Message 1 of 6

Print all the blocks in different sheets

sarahFCCM2
Explorer
Explorer

Hello! I have more than 300 blocks in a CAD file. I would like to have all of them printed in different PDF or JPG or PNG files (One block per file). Is there a way to do it smartly?

Thank you in advance.

0 Likes
Accepted solutions (1)
931 Views
5 Replies
Replies (5)
Message 2 of 6

maratovich
Advisor
Advisor
Accepted solution

Maybe this will help you - Revers 
Print from Layouts and Model.

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
Message 3 of 6

ronjonp
Mentor
Mentor

Maybe this?

 

(defun c:foo (/ a p p1 p2 s)
  ;; RJP » 2021-06-29
  (cond	((setq s (ssget "_X" '((0 . "INSERT") (410 . "MODEL"))))
	 (setq p (getvar 'dwgprefix))
	 (setq a (vlax-get-acad-object))
	 (foreach b (mapcar 'cadr (ssnamex s))
	   (vla-getboundingbox (vlax-ename->vla-object b) 'p1 'p2)
	   (vla-zoomwindow a p1 p2)
	   (command "_.pngout" (strcat p (cdr (assoc 2 (entget b)))) b "")
	 )
	)
  )
  (princ)
)

 

0 Likes
Message 4 of 6

3wood
Advisor
Advisor

You can also try LISTBLOCK.

To print all blocks as a pdf file, you need set up a printer in Model space first, such as 'DWG to PDF.pc3'. 

Then use LISTBLOCK with settings below.

listblocks.PNG

0 Likes
Message 5 of 6

Sea-Haven
Mentor
Mentor

Another, note had to add a couple of no plot block names, the Aecc* blocks are part of Civ3D. There may be more.

 

Just start with block dwg and have Model space blank. I have 196 blocks it got to 83 so have another screwy block to find. Found "_none" at 83 rd entry.

 

(defun c:foo2 (/ p p1 p2 blk bame)
(setvar 'ctab "Model")
	 (setq p (getvar 'dwgprefix))
	 (setvar 'filedia 0)
	(vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
		(setq bname  (vla-get-name blk))
		(if  (or  (wcmatch bname "*_Space*")(wcmatch bname "Aecc*")(wcmatch bname "*X9*"))
		(princ "skipped")
			(progn
				(command  "-INSERT" bname (list 0 0) 1 1 0)
				(command "zoom" "Extents")
				(command "-.pngout" (strcat p bname)(entlast) "")
				;(command "_.pngout" (strcat "D:\\ACADTEMP\\PNG\\" bname)(entlast) "")
				(command "erase" (entlast) "")
			)
		)
	)
  (princ)
)
(c:foo2)

Block names

(princ (vla-get-count (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))))

(vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
(princ (strcat "\n" (vla-get-name blk)))
)

 

0 Likes
Message 6 of 6

sarahFCCM2
Explorer
Explorer

Thank you so much! This works pretty well! 

0 Likes