Message 1 of 7

Not applicable
12-15-2016
03:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I iterate over BlockTableRecord Layout to get extents3d collection, and then get mtext and dbtext inside extents3d by function SelectWindow.
But I dont get text collection approximately (Ex: I have 3 extents have 3 text "a", "b", "c", but the results i get only two texts randomly.)
I catch error by drawing line (pt1, pt2), pt1 and pt2 are bounds of extents, then it draws correct line is diagonal line of extents.
But text got was still incorrect. Was this is SelectionWindow's Error? Help me, please.
//Here the code of main class Extents3d acTxtExt3d = acSC.GetExtents3dFromInsertPointOfBlockReferenceAndTwoVectorsWithScale(acBlkRef1, acTxtVec3dOrgArr, acScl3dOrg); //Get extents3d area have text Line acLine = new Line(acTxtExt3d.MinPoint, acTxtExt3d.MaxPoint); acLine.SetDatabaseDefaults(); //Draw a line to catch error acBlkTblRecSpc.UpgradeOpen(); acBlkTblRecSpc.AppendEntity(acLine); acTrans.AddNewlyCreatedDBObject(acLine, true); acBlkTblRecSpc.DowngradeOpen(); //Append line to CurrentSpace // Get Mtext or Text from function of subclass (SelectWindow) DBObject acDbObj = acSC.GetTextInsideExtents3d(acDoc1, acTrans, acTxtExt3d); string txt = ""; // -> Get error here if (acDbObj is DBText) { Application.ShowAlertDialog(((DBText)acDbObj).TextString); txt = ((DBText)acDbObj).TextString; } if (acDbObj is MText) { Application.ShowAlertDialog(((MText)acDbObj).Contents); txt = ((MText)acDbObj).Contents; } // Here is the code of sub class to get Text or Mtext inside a SelectWindow // Only one text in SelectWindow is valid. public DBObject GetTextInsideExtents3d( Document acDoc,Transaction acTrans, Extents3d acExt3d) { Editor acDocEd = acDoc.Editor; TypedValue[] acTypValAr = new TypedValue[4]; acTypValAr.SetValue(new TypedValue((int)DxfCode.Operator, "<OR"), 0); acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "TEXT"), 1); acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "MTEXT"), 2); acTypValAr.SetValue(new TypedValue((int)DxfCode.Operator, "OR>"), 3); SelectionFilter acSFil = new SelectionFilter(acTypValAr); SelectionSet acSSet; Point3d acPt1 = new Point3d(acExt3d.MinPoint.X , acExt3d.MinPoint.Y , 0); Point3d acPt2 = new Point3d(acExt3d.MaxPoint.X, acExt3d.MaxPoint.Y, 0); PromptSelectionResult acPSRes = acDocEd.SelectWindow(acPt1, acPt2, acSFil); if (acPSRes.Status == PromptStatus.OK) { acSSet = acPSRes.Value; if (acSSet.Count == 1) { DBObject acDbObj = null; foreach (ObjectId item in acSSet.GetObjectIds()) { acDbObj = acTrans.GetObject(item, OpenMode.ForRead); } return acDbObj; } else return null; } else return null; }
Solved! Go to Solution.