Hello everyone .
It seems that my TypedValue structure is wrong because I could not select Texts or Mtext nor anything when I ran the program . strange
Could someone help me to modify the codes ?
TypedValue[] Tvalues = new TypedValue[] { new TypedValue(0, "TEXT"), new TypedValue(0, "MTEXT") };
It seems this modification is working with wild-cards .
Is this correct ?
TypedValue[] Tvalues = new TypedValue[] { new TypedValue(0, "*TEXT") };
your last pattern call is correct, but also try to separate the pattern with commas, in example:
TypedValue[] typedValues = { new TypedValue((int)DxfCode.Start, "LINE,ARC,LWPOLYLINE,POLYLINE,CIRCLE,SPLINE,ELLIPSE") };
hth.-
Thanks LE that works very well .
I am trying to write a program to select text strings that match a specific text string "BedRoom" , and my question is : how can I highlight if the list contained values ( text strings "BedRoom" ) ?
Regards
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { Editor ed = acDoc.Editor; TypedValue[] Tvalues = new TypedValue[] {new TypedValue((int)DxfCode.Start,"TEXT,MTEXT")}; SelectionFilter fltr = new SelectionFilter(Tvalues); PromptSelectionResult SSprompt; SSprompt = acDoc.Editor.GetSelection(fltr); if (SSprompt.Status == PromptStatus.OK) foreach (SelectedObject item in SSprompt.Value) { DBObject obj = acTrans.GetObject(item.ObjectId, OpenMode.ForRead) as DBObject; MText mtext = obj as MText; if (mtext != null && mtext.Contents=="BedRoom") { mylist.Add(mtext.Contents); ed.WriteMessage(mtext.Contents + System.Environment.NewLine); } else { DBText text = obj as DBText; if (text != null && text.TextString == "BedRoom") { mylist.Add(text.TextString); ed.WriteMessage(text.TextString + System.Environment.NewLine); } } } }
that sounds like you want to have a similar Find (built-in-command) tool, looks like you maybe able to use the TextEditor Class - read about this on the arxmgd.chm - it might help.
I read about this TextEditor class but it seems a little bit difficult to a biginner guy like me , can you give me an example if it is not that bothering ?
Thank you
sorry, don't have time for that, and also no need for a tool like this as i am not an autocad user anymore.
maybe there is something already there (similar) never knows in the net, good luck!
see, KEAN WALMSLEY great site about autocad, has an usage sample of this class:
just need to do a search.... hth.-
This uses extension methods that are posted at the swamp but should be easy to tell what little typing it saves
for example
var mtxt = item.GetEntity<MText>(); ///////Change to DBObject obj = acTrans.GetObject(item.ObjectId, OpenMode.ForRead) as DBObject; MText mtext = obj as MText;
private static IntPtr mtxtPtr = RXObject.GetClass(typeof(MText)).UnmanagedObject; [CommandMethod("roomnameHighlight")] public void roomnameHighlight() { using (Transaction trx = Db.TransactionManager.StartTransaction()) { AllowedClassFilter acf = new AllowedClassFilter(typeof(MText), typeof(DBText)); PromptSelectionResult selResult = Ed.GetSelection(acf); if (selResult.Status != PromptStatus.OK){return;} foreach (var item in selResult.Value.GetObjectIds()) { if (item.ObjectClass.UnmanagedObject == mtxtPtr) { var mtxt = item.GetEntity<MText>(); if (mtxt.Text.Equals("RoomName", StringComparison.OrdinalIgnoreCase)) { mtxt.Highlight(); } } else { var txt = item.GetEntity<DBText>(); if (txt.TextString.Equals("RoomName", StringComparison.OrdinalIgnoreCase)) { txt.Highlight(); } } } trx.Commit(); } }
Thank you jeff for your help .
I have an error on
Intptr
and
AllowedClassFilter
but the HighLight Method works and I just add it to my codes and it works , though I am looking for a way to SELECT and not just to HIGHLIGHT.
The HighLight method is not clear enough to see the highlighted objects if I have many objects .
Thank you.
Can't find what you're looking for? Ask the community or share your knowledge.