Create image from Geometry

Create image from Geometry

BrentBurgess1980
Collaborator Collaborator
842 Views
4 Replies
Message 1 of 5

Create image from Geometry

BrentBurgess1980
Collaborator
Collaborator

Hi All,

 

I am trying to create an image of of a polyline to be used in an image, however, I have not been able to find anything that would help.

 

I have tried creating a block but this hasn't been as successful as I'd hoped.

 

If it were just straight line segments, I could probably conjure something up with points and draw an image, but as there may be curves in the polyline, I am not sure how I would tackle that.

 

I have googled

Image from Entity

Copy Entity to Clipboard (thinking I could use the image)

Generate Bitmap from Entity

and other variations of the above.

 

Does anyone have any tips or references for this?

 

Thanks,

Brent

0 Likes
843 Views
4 Replies
Replies (4)
Message 2 of 5

SENL1362
Advisor
Advisor

And the problem is?

Have a look at CapturePreviewImage

Sample:

 

 

 

...
//Turn layers on/off and or set LineWeight
db.UpdateExt(true);
dynamic acadApp = AcadApp.AcadApplication;
acadApp.ZoomExtents();
ed.ZoomScale(1.03);
...
var size = doc.Window.DeviceIndependentSize;
using (var bmp = doc.CapturePreviewImage(Convert.ToUInt32(size.Width), Convert.ToUInt32(size.Height)))
{
//TopLeft Pixel must be backgroud to make it transparent, use ZoomScale(1.03)
var firstPxl = bmp.GetPixel(0, 0);  //255,0,0  white or Black
bmp.MakeTransparent(firstPxl);
if (File.Exists(IconPathname))
File.Delete(IconPathname);
bmp.Save(IconPathname, System.Drawing.Imaging.ImageFormat.Png);
}

 

 

 

 

Message 3 of 5

R.Gerritsen4967
Advocate
Advocate

Instead of using the PreviewImage of a drawing you can also make a plot to a file.

See this example for plotting to a PDF file. If you change the plotconfiguration file to the 'PublishToWeb PNG.pc3', it is possible to plot to a .png file.

 

0 Likes
Message 4 of 5

hippe013
Advisor
Advisor

Did you happen to read Kean's updated post regarding the original link that you posted about generating an image from blocks? 

 

https://through-the-interface.typepad.com/through_the_interface/2013/11/generating-larger-preview-im...

0 Likes
Message 5 of 5

BlackBox_
Advisor
Advisor

@SENL1362 wrote:

 

...
//TopLeft Pixel must be backgroud to make it transparent, use ZoomScale(1.03)
var firstPxl = bmp.GetPixel(0, 0);  //255,0,0  white or Black
bmp.MakeTransparent(firstPxl);
...

 


Love that lil' trick: 

 

https://forums.augi.com/showthread.php?172533-PNGOUT-with-transparent-background-option&p=1338401&vi... 


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes