private static NODEDWG GetData(Database db, SQLiteConnection connection) { NODEDWG note = new NODEDWG(); using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead); foreach (ObjectId id in btr) { DBObject obj = tr.GetObject(id, OpenMode.ForRead); if (obj is BlockReference) { BlockReference bref = (BlockReference)obj; if (Goodies.IsBlockInTheDrawing(bref)) { if (bref.IsDynamicBlock) { string brefName = Goodies.GetDynamicName(bref); if (brefName.Equals(ConstantName.FixtureInformationArea)) { FixtureBeingUsedArea dbA = new FixtureBeingUsedArea(bref); if (dbA.model != null) { note.FixtureBoxSet.Add(dbA); } } } else if (bref.Name == ConstantName.FixtureDetailsBox) { FixtureDetails FD = new FixtureDetails(bref, tr); if (FD.model != null) { note.FixtureDetailSet.Add(FD); } } else if (bref.Name == ConstantName.InsertPoint) { InsertPoint IP = new InsertPoint(bref, tr); if (IP.model != null) { note.InsertPointSet.Add(IP); } } else if (bref is Table) { TableData tb = new TableData(bref, tr, db); if (tb.model != null) { note.TableDataSet.Add(tb); } } } } } List <FixtureDetails> newFixs = new List <FixtureDetails>(); foreach (FixtureBeingUsedArea fba in note.FixtureBoxSet) { foreach (FixtureDetails fd in note.FixtureDetailSet) { if (fba.IsInsideTheBox(fd)) { newFixs.Add(fd); } } } note.FixtureDetailSet.Clear(); foreach (FixtureDetails fd in newFixs) { note.FixtureDetailSet.Add(fd); } } //Write to Database string currentdwgPath = db.Filename; string dbPath = GoodiesPath.GetDatabasePathFromDwgPath(currentdwgPath); if (string.IsNullOrEmpty(dbPath)) { MessageBox.Show("Could Not Find Database."); } note.file = DBDwgFile.GetPNote(connection); note.file.modifieddate = GoodiesPath.GetModifiedOfFile(GoodiesPath.GetFullPathFromRelativePath(note.file.relativePath, connection)).Ticks; if (note.file == null) { MessageBox.Show($"Can't find this {currentdwgPath} in databse."); return(null); } foreach (FixtureBeingUsedArea fixtureBox in note.FixtureBoxSet) { fixtureBox.model.file = note.file; } foreach (FixtureDetails fd in note.FixtureDetailSet) { fd.model.file = note.file; } foreach (InsertPoint ip in note.InsertPointSet) { ip.model.file = note.file; } foreach (TableData table in note.TableDataSet) { table.model.file = note.file; } DBDwgFile.DeleteRow(connection, note.file.relativePath); note.WriteToDataBase(connection); return(note); }
public FixtureUnit(BlockReference bRef, Transaction tr) { model = new FixtureUnitModel(); model.position = new Point3dModel(bRef.Position.ToArray()); model.matrixTransform = new Matrix3dModel(bRef.BlockTransform.ToArray()); model.blockName = Goodies.GetDynamicName(bRef); model.fuS = FixtureUnitBlock.GetFixtureUnitStatus(model.blockName); Point3d v, m, r1; foreach (DynamicBlockReferenceProperty prop in bRef.DynamicBlockReferencePropertyCollection) { if (prop.PropertyName == FixtureUnitModelName.A1) { model.A1 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.A2) { model.A2 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.A3) { model.A3 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.D1) { model.D1 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.Y2) { model.Y2 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.X2) { model.X2 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.X2_2) { model.X2_2 = (double)prop.Value; } else if (prop.PropertyName == FixtureUnitModelName.V) { v = (Point3d)prop.Value; model.V = new Point3dModel(v.X, v.Y, v.Z); } else if (prop.PropertyName == FixtureUnitModelName.M) { m = (Point3d)prop.Value; model.M = new Point3dModel(m.X, m.Y, m.Z); } else if (prop.PropertyName == FixtureUnitModelName.R1) { r1 = (Point3d)prop.Value; model.R1 = new Point3dModel(r1.X, r1.Y, r1.Z); } } foreach (ObjectId id in bRef.AttributeCollection) { AttributeReference attRef = (AttributeReference)tr.GetObject(id, OpenMode.ForRead); if (attRef.Tag == FixtureUnitModelName.CWSFU) { model.CWSFU = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.WSFU) { model.WSFU = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.HWSFU) { model.HWSFU = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.VENT_DIA) { model.VENT_DIA = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.WASTE_DIA) { model.WASTE_DIA = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.STORM_DIA) { model.STORM_DIA = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.DFU) { model.DFU = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.HW_DIA) { model.HW_DIA = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.CW_DIA) { model.CW_DIA = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.INDEX) { model.INDEX = Convert.ToDouble(attRef.TextString); } else if (attRef.Tag == FixtureUnitModelName.TAG) { throw new Exception("Check This Out."); } } }