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
Solved! Go to Solution.
Solved by gpuerini. Go to Solution.
The easiest answer is to call:
databaseFromFile.CloseInput(true);
after reading the database and before accessing the data.
-GP
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
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.)