Export material hatch pattern into raster image

Export material hatch pattern into raster image

Anonymous
Not applicable
1,087 Views
1 Reply
Message 1 of 2

Export material hatch pattern into raster image

Anonymous
Not applicable

Hi,

 

I would like to export the hatch pattern of a material into an image (*.png, *.jpg...). Since the hatch pattern is vector and the image is raster, is there any API to do that? Here is my code snippet:

 

Material material = document.GetElement(materialId) as Material;
var fillPatternElement = document.GetElement(material.SurfacePatternId) as FillPatternElement;
if (fillPatternElement != null)
{
    FillPattern fillPattern = fillPatternElement.GetFillPattern();
    IList<FillGrid> fillGrids = fillPattern.GetFillGrids();
    foreach (FillGrid fillGrid in fillGrids)
    {
        // Do something to generate image texture from hatch pattern
    }
}

Thank you.

0 Likes
1,088 Views
1 Reply
Reply (1)
Message 2 of 2

JimJia
Alumni
Alumni

Dear khoa.ho,

 

Please refer to Jeremy's blog

 

http://thebuildingcoder.typepad.com/blog/2015/11/fill-pattern-viewer-fix-and-add-materials-2016.html

 

You can also get the complete codes there.

 

Pay attention to method "DrawFillPattern", it can export the fillpattern to bitmap format, then you can save bitmap to other format(such as .jpg,.png) as you wish.

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes