Extract images of blocks that are in layer.

Extract images of blocks that are in layer.

Dan-Rod
Advocate Advocate
977 Views
10 Replies
Message 1 of 11

Extract images of blocks that are in layer.

Dan-Rod
Advocate
Advocate

hi

I would like to know if there is a way to be able to extract images of the blocks that I have in the drawing, send to a folder the images of all the blocks that I have and that are related to a specific layer, this is because I only require the image of certain blocks and not those of everyone who is in the drawing.

I attach a "test" drawing, in this case I would like to extract the images of the blocks that are in the layer '"fig"

 

I attach a couple of images of how it is required to come out.

0 Likes
Accepted solutions (1)
978 Views
10 Replies
Replies (10)
Message 2 of 11

Sea-Haven
Mentor
Mentor

Look at PLOT "Publish to web". Used it all the time and TIFF and WMF. In Bricscad V20 no JPG option. Just get  a bounding box of block for the window and use that in a (command "Plot" .............

 

0 Likes
Message 3 of 11

Dan-Rod
Advocate
Advocate

Thank you for taking the time to respond.

We do not have that application that you mention, the idea of ​​​​seeing if the images could be extracted was because I currently have a modeling program called NX, in it there is a macro that can do this, enter the model block, take the photo and send to a folder.

For AutoCAD, I don't know if something similar could be done using a LISP routine or if something more elaborate is required.

0 Likes
Message 4 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Possibly like this. Note that the picture size is given by the current screen size and it's not adjustable with this command. It prints all blocks in the CURRENT layer.

 

(defun c:BlocksToPng ( / s i e n l f x)

  (or *BlocksToPng-folder* (setq *BlocksToPng-folder* (getvar 'dwgprefix)))
  
  (if (and (setq s (ssget "_X" (list '(0 . "INSERT") (cons 8 (getvar 'clayer)) (cons 410 (getvar 'ctab)))))
	   (setq *BlocksToPng-folder* (acet-ui-pickdir "Specify output folder" *BlocksToPng-folder*))
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    n (cdr (assoc 2 (entget e))))
      (if (and (not (vl-position n l))
	       (or (snvalid n 0) (prompt (strcat "\n'" n '" not valid filename. Ignored."))))
	(progn
	  (setq l (cons n l))
	  (setq f (strcat *BlocksToPng-folder* "\\" n))
	  (setq x (findfile f))
	  (command "_.zoom" "_o" e "")
	  (command "_.pngout" f)
	  (if x (command "_y"))
	  (command e "")))))
  (princ)
  )

 

Message 5 of 11

Dan-Rod
Advocate
Advocate

I try to run the program and nothing happens. Is there any information you are omitting?

0 Likes
Message 6 of 11

hak_vz
Advisor
Advisor

@Dan-Rod 

 

I've tested code from @ВeekeeCZ  and it works perfectly. You have to learn read the autolisp code and addopt. Don't need to be programmer but some basics are needed.

In particular case in his code we have:

(ssget "_X" (list '(0 . "INSERT") (cons 8 (getvar 'clayer)) (cons 410 (getvar 'ctab))))

It says select all blocks in current layer (getvar 'clayer) and in current workspace i.e model or layout tab.

To test change in test file current layer to Simb1 and see how magic is happening.

 

@ВeekeeCZ  I like it!

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 7 of 11

Dan-Rod
Advocate
Advocate

wow, that's it, thanks for the information,

I'm really just getting to know the benefits of lsp, in this forum I have found several solutions, I know very little about programming but in particular this language seems somewhat confusing to me, thank you, it works very well and is what I needed, in fact the issue of coordinates that you supported, I would precisely be adding blocks of this type, now it would be necessary to get each block to the grid, the attribute would be the 'INDICE' number, do you think it is possible?

0 Likes
Message 8 of 11

Sea-Haven
Mentor
Mentor

Not sure what you want, could pick a block "Jacket" and send to 16. 

SeaHaven_0-1709597626524.png

Can you post a before and after dwg.

 

 

 

0 Likes
Message 9 of 11

Dan-Rod
Advocate
Advocate

Hello again, I am looking to sequence, through an attribute, blocks of the file, there would be 3 variants and I don't know how possible it is, one of them would be from 1 to the last block, the second option from 0 to 63, and the last from 1 to 100, today I upload the example because as I mentioned doing it manually is time consuming, if it could be done through a routine it would save me a lot of time

0 Likes
Message 11 of 11

hak_vz
Advisor
Advisor

@Dan-Rod Yes it is possible but it is actually inverse operation from what we have now. Try to describe your complete process in your original post and I'll do whatever is needed. Something like, first put all blocks to appropriate size boxes all around the grid. This can be done from input list that is created form let say an order or whatever. Then place this boxes into the grid and output location list. A kind of a Sokoban game if you ever playedit.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes