How does one do this in AutoLISP ?
Let us say I have a drawing with 5 layers. How do I generate a 1-bit (not full color) BMP export (user defined size) for each layer separately ?
The resulting BMP images will obviously be black and white.
@Anonymous wrote:How does one do this in AutoLISP ?
Let us say I have a drawing with 5 layers. How do I generate a 1-bit (not full color) BMP export (user defined size) for each layer separately ?
The resulting BMP images will obviously be black and white.
I could work out how to EXPORT or BMPOUT .bmp images of each Layer's contents separately, but I don't know of a way to make the results black & white [at least not from inside AutoCAD -- presumably you could open the resulting Bitmap images and edit them with some other program]. Is that an option that's been added to those commands in later versions of AutoCAD than my ol' 2004?
I do not know.
I am currently exporting each layer separately manually and then using Matlab to convert it into a 1-bit bitmap. I guess it was too much to expect a layout program to do image manipulation as well 🙂
But I would be thrilled with a BMP export (I am lazy, that is why I like scripting).
Manually, I do it by switching of all layers but the current one. Exporting and repeat.
I will try to figure this out but your help would be appreciated.
PS: Is it possible to access the shell from within AutoLISP ? Something like : (system "string containing the shell command") ?
My laziness has few bounds 🙂
@Anonymous wrote:....
Manually, I do it by switching of all layers but the current one. Exporting and repeat.
I will try to figure this out but your help would be appreciated.
....
As a starter: Making a list of Layers in the drawing is easy enough [see Message 2 on the recent "Alphabetic Sort?" thread]. Then you would want to step through that list, and for each Layer name in it, use Export or Bmpout to make a file of its contents. It isn't necessary to set each Layer current or turn others off. Those commands want object selection, and you can use selection-set filtering in (ssget) to find everything on a particular Layer. There are many examples of that in this forum. You can use each Layer's name both for selection filtering and presumably as part of the .bmp file name.
EDIT: Actually, in this case you could use (tblnext) to step through the Layer names, rather than making a list of them. [That other thread had a reason to want them sorted, but I assume that wouldn't matter in your case.]
Ok. Let us make things complicated.
Let us say that I want to export only the region enclosed by pt1, pt2, pt3 and pt4 to a BMP. These four points describe a rectangle.
I am essentially trying to crop before export, accurately.
If I draw a non-square region, the export is still a square (with blank space making up the balance) if I choose entire region.
@Anonymous wrote:....
Let us say that I want to export only the region enclosed by pt1, pt2, pt3 and pt4 to a BMP. These four points describe a rectangle.
I am essentially trying to crop before export, accurately.
....
I don't think you can do that, in EXPORT or BMPOUT at least, except perhaps by stretching the AutoCAD window itself so that the displayed screen area shows only the extent of what you want to have in your .bmp file.
Help for BMPOUT says "The file reflects what is displayed on the screen," though I guess they mean that in terms of extent, because of course it only includes objects you select. Unfortunately you can't do it with Zoom Window using opposite corners of your rectangle, because unless that's proportioned exactly the same as the display area, the display will show more area either above and below or at the sides, and that larger displayed area will go to the .bmp file.
You're probably stuck with exporting a bigger area than you want, and cropping it in some other program. You could presumably put Points at the corners of the desired area [if there isn't some kind of border drawn otherwise], and include them in the EXPORT/BMPOUT, to give you something to crop to.