.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Prevent layer object from selection

1 REPLY 1
Reply
Message 1 of 2
Anonymous
265 Views, 1 Reply

Prevent layer object from selection

Can any one tell me how to prevent layer object from selecting using c#. I am using the following c# code

public static void Remove selection(StringBuilder szLayer)
{
ObjectId objId = new ObjectId();

Database db = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
LayerTable layerTable = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForRead);
string Layername = szLayer.ToString();
foreach (ObjectId obj in layerTable)
{
if ((layerTable.Has(Layername)) && layerTable[Layername] != db.Clayer)
{

objId = layerTable[Layername];
}
}
if (objId != null)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptSelectionResult psrres = ed.GetSelection();

SelectionSet psr = psrres.Value;
if (psr.Count > 0)
{
for (int i = 0; i <= psr.Count; i++)
{
if (psr.ObjectId == objId)
{

----> how to remove the given layer from selection
}

}
}

} Edited by: shamsam1 on May 30, 2009 1:05 PM
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

See the Editor's SelectionAdded Event and look at this newsgroup for
samples.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6192371@discussion.autodesk.com...
Can any one tell me how to prevent layer object from selecting using c#. I
am using the following c# code public static void Remove
selection(StringBuilder szLayer) { ObjectId objId = new ObjectId(); Database
db = HostApplicationServices.WorkingDatabase; using (Transaction trans =
db.TransactionManager.StartTransaction()) { LayerTable layerTable =
(LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForRead); string
Layername = szLayer.ToString(); foreach (ObjectId obj in layerTable) { if
((layerTable.Has(Layername)) && layerTable[Layername] != db.Clayer) { objId
= layerTable[Layername]; } } if (objId != null) { Editor ed =
Application.DocumentManager.MdiActiveDocument.Editor; PromptSelectionResult
psrres = ed.GetSelection(); SelectionSet psr = psrres.Value; if (psr.Count >
0) { for (int i = 0; i <= psr.Count; i++) { if (psr.ObjectId == objId)
{ ----> how to remove the given layer from selection } } } } Edited by:
shamsam1 on May 30, 2009 1:05 PM

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost