AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

c# - wall net area is wrong when looking at wall directly from the database.

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
gpuerini
513 Views, 4 Replies

c# - wall net area is wrong when looking at wall directly from the database.

Our program used the wall are properties

_areaGrossRight = mywall.Area(WallSide.Right, false);
_areaGrossLeft = mywall.Area(WallSide.Left, false);
_areaNetRight = mywall.Area(WallSide.Right, true);
_areaNetLeft = mywall.Area(WallSide.Left, true);

 

These areas are calculated correctly when pulling the wall from the active drawing database.

However, when the drawing ins NOT opened and the database is read directly from the file via:

 

 Database databaseFromFile.ReadDwgFile(fileName);

 

The net and gross area are the same, even when there are opening in the wall.

 

I'm assuming why I read directly from the database, the program simply does not do the math?

Is there any way around this? A function I can call or something?

 

We are testing this in ACA2015

THanks

-Gary Puerini

 

 

4 REPLIES 4
Message 2 of 5
gpuerini
in reply to: gpuerini

fyi.. same results when looking at component bodies.
same value if "cutOpenings" is true or false.
cutOpenings = true;
mywall.GetComponentBodies(out bcNet, simple3d, cacheIt, doMerger, cutOpenings, cutInterference, applyBodyModifiers, modelOpeningEndCaps);
Message 3 of 5
gpuerini
in reply to: gpuerini

The easiest answer is to  call:

 

 databaseFromFile.CloseInput(true);

 

after reading the database and before accessing the data.

-GP

 

Message 4 of 5
jeremytammik
in reply to: gpuerini

To answer the follow-up question as well:

 

Question

 

I am trying to collect consistent values of a wall by accessing the wall object in the database directly.

 

However, I still get wrong values when it comes to the left/right areas of a wall that cleans up with another wall (ie the corner of a house).

 

When collecting the wall directly from a database, both the left and right areas are collected as the same, when the inside side should have less area.

 

What can I do to fix this problem?

 

Answer

 

Here is a sample code snippet and explanation:

 

  using (var db = new Database(false, true))
  {
    db.ReadDwgFile(@"...dwg", FileShare.None, false, null);
    db.CloseInput(true);
    var walls = new ObjectIdCollection();
    using (var trans = db.TransactionManager.StartTransaction())
    {
      var bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead, false);
      var btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead, false);
      var manager = new Autodesk.Aec.Arch.DatabaseServices.WallSystem.Manager(db);
      foreach (ObjectId i in btr)
      {
        var wall = trans.GetObject(i, OpenMode.ForRead) as Wall;
        if (wall != null)
        {
          walls.Add(i);
          manager.UpdateWallInWallSystem(wall);
        }
      }
      trans.Commit();
    }

    using (var trans = db.TransactionManager.StartTransaction())
    {
      foreach (ObjectId i in walls)
      {
        var wall = (Wall)trans.GetObject(i, OpenMode.ForRead);
        Debug.Print("{0}\t{1}\t{2}", wall.Location, wall.Area(WallSide.Left, false), wall.Area(WallSide.Right, false));
      }
      trans.Commit();
    }
  }

 

The key is using the wall system manager to force an update on the relationship of all walls in the first loop.

 

Once the relationship ha been completely built, areas can be calculated as expected in the second loop.

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 5
gpuerini
in reply to: jeremytammik

The fix for the wall area seems to work great! thanks so much!

(I am fighting a memory crash with it, but I believe it has nothing to do with you code and is just a coincidence that it happened after I tried it out.)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost