There was no need, in the code I posted, for the
block({}) around the code after the if statement.
Note the return, don't confuse with:
if()
{
}
Here is that portion without the {}.
[/code]
if (psr.Status != PromptStatus.OK) return;
ObjectIdCollection idCol =
new ObjectIdCollection(psr.Value.GetObjectIds());
using (Transaction tr =
db.TransactionManager.StartTransaction())
{
foreach (ObjectId id in idCol)
{
DBText dbt = (DBText)tr.GetObject
(id, OpenMode.ForRead, false);
if (((String)dbt.TextString).Contains(txtToFind))
{
//rip it up.
}
}
}
[/code]
"Paul Richardson"
wrote in message
news:5265057@discussion.autodesk.com...
Wow was that ugly...Here's a txt file.
"Paul Richardson" wrote in message
news:5265051@discussion.autodesk.com...
It's in c#, but should give you the idea.
Sample call:
SSFilter("Text", "Layer1", "bar");
[code]
public static void SSFilter(string entType,
string layerName, string txtToFind)
{
Editor ed = Autodesk.AutoCAD.ApplicationServices.
Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationS
ervices.WorkingDatabase;
TypedValue[] filter = new TypedValue[2]
{
new TypedValue((int)DxfCode.Start, entType),
new TypedValue((int)DxfCode.LayerName, layerName)
};
SelectionFilter filterSS = new SelectionFilter(filter);
PromptSelectionResult psr = ed.SelectAll(filterSS);
if (psr.Status != PromptStatus.OK) return;
{
ObjectIdCollection idCol =
new ObjectIdCollection(psr.Value.GetObjectIds());
using (Transaction tr =
db.TransactionManager.StartTransaction())
{
foreach (ObjectId id in idCol)
{
DBText dbt = (DBText)tr.GetObject
(id, OpenMode.ForRead, false);
if (((String)dbt.TextString).Contains(txtToFind))
{
//rip it up.
}
}
}
}
}
[/code]
wrot
e in message news:5264843@discussion.autodesk.com...
Yes, you would be right. I am changing "TheStringToFind".
Exactly what I am doing is checking the layer to see if a specific string
already exist before placing it on the layer. I just haven't figured out a
way to search or find text.