Block.Boundingbox for text shows incorrect values

Open
#849 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp

Research direction

Start by reproducing the report with the attached DWG files and the supplied C# example, focusing on Insert.GetBoundingBox() for a block containing text but no lines. Compare the returned height and width with the expected bounds; the issue does not name a test or source file.

Written by the indexing model from the issue text.

Description

bug

Hi Dom,

I have inserted a block and tried to find its boundingbox of height and width. it is working fine when it has lines but if it has only text then it shows incorrect values. Can you check this issue.

string TEMPpath = @"D:\Tools Development\ACAD\Text Bounding Box\empty.dwg";
String Docpath = @"D:\Tools Development\ACAD\Text Bounding Box\DIP-SWITCH-SETTING-NOTE.dwg";
string outpath1 = @"D:\Tools Development\ACAD\Text Bounding Box\textboundingbox.dwg";

CadDocument template = DwgReader.Read(TEMPpath, onNotification);
       

var insertpoint = new XYZ(25, 250, 0.0);
var blockInsert = InsertBlock(Docpath, insertpoint);
Insert InsertBlock(string path, XYZ insertpoint)
{
    CadDocument doc = DwgReader.Read(Docpath, onNotification);
    BlockRecord newBlock = new BlockRecord("New block");
    foreach (var ent in doc.Entities)
    {
        var entclone = ent.Clone() as Entity;

        newBlock.Entities.Add(entclone);
    }
    template.BlockRecords.Add(newBlock);
    var base1 = newBlock.BlockEntity.BasePoint;
    var base2 = doc.Header.ModelSpaceInsertionBase;
    newBlock.BlockEntity.BasePoint = base2;
    
    var blockInsert = new ACadSharp.Entities.Insert(newBlock)
    {
        InsertPoint = insertpoint // Set the insertion point
    };
   
    return blockInsert;
}
blockInsert.Block.IsExplodable = true;
template.Entities.Add(blockInsert);

var bbox = blockInsert.GetBoundingBox();
var Height = bbox.Height;
var Width= bbox.Width;
DwgWriter.Write(outpath1, template);

Text Bounding Box.zip

Dominant language
C#
Stars
873
Forks
223
Avg merge
1d 15h
Merged PRs (30d)
28

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DomCR/ACadSharp

All issues in DomCR/ACadSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.