Adding dimensions to drawing

1
Bilih
8/18/2021 9:37 AM

Hi! I'm currently trying to develop a asp.net webform in c# that will allow users of the webpage to upload a dxf to the webpage and the webpage will show a preview of the dxf with it's measurements to the user. To do this, i'm currently using a function which given the path of the dxf file, returns a base64 image string which is then displayed in a picturbox
Currently i'm using the following code,

C# Code:
    public string Base64ImageFromDxf(string path)
    {
        DxfModel model = DxfReader.Read(path);
      

        GraphicsConfig graphicsConfig = new GraphicsConfig();
        graphicsConfig.BackColor = System.Drawing.Color.Transparent;
        graphicsConfig.FixedForegroundColor = System.Drawing.Color.Black;

        using (Bitmap bitmap = ImageExporter.CreateAutoSizedBitmap(
            model,
            Matrix4D.Identity,
            graphicsConfig,
            SmoothingMode.HighQuality,
            new Size(1000, 750)
        ))
        {
            using (MemoryStream ms = new MemoryStream())
            {
                //Save the image as PNG to a memory stream and encode it into a base64 string that can be used in the html img src tag.
                bitmap.Save(ms, ImageFormat.Png);
                string imageBase64 = Convert.ToBase64String(ms.ToArray());
                string imageData = string.Format("data:image/png;base64,{0}", imageBase64);
                return imageData;
            }
        }
        
    }

but i'm missing to add the dimensions entities. I've tried with

C# Code:
DxfDimension.Aligned dxfDimension = new DxfDimension.Aligned(model.CurrentDimensionStyle);
model.Entities.Add(dxfDimension);

right after the model read but when i do this, i get the normal image with a very tiny dot that i suspect that is the "wrong" dimentions indicator [sample error.png]

The goal would be to make something like the attached image [sample objective.png]

Wout
8/18/2021 9:53 AM

Hi,

The documentation contains examples of how to create dimensions (for each type of dimension), have you tried those?

- Wout

Bilih
8/19/2021 6:43 AM

I haven't been able to find those examples in the documentation. Kindly, would you please indicate me where i can find those? Thank you!

Wout
8/19/2021 8:43 AM

See here.

- Wout

1