here is my question :
I want to access FASTSEL command from c# , to find connected entities from given input ,
double x = (entity as Arc).StartPoint.X;
double y = (entity as Arc).StartPoint.Y;
doc.SendStringToExecute($"Select touching object: {x},{y}" + " ", true, false, true);
but following above code ,this is behaving asynchronous way , I want synchronous way answer
so I tried below mentioned code,
ResultBuffer pa = new ResultBuffer();
pa.Add(new TypedValue(5005, "c:fastsel"));
pa.Add(new TypedValue(5002, new Point2d(ent.StartPoint.X, ent.StartPoint.Y)));
ResultBuffer rb = Application.Invoke(pa);
here am facing issue like error too many arguments , may I know what is the correct format for passing the arguments for fastsel command? kindly help me out from this
thanks in advance
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Hi,
The LISP function c:fastsel have to be called with none argument.
Most of the times, mixing LISP and .NET is more difficult than doing things in plain LISP or plain .NET.
Implement what FASTSEL does in plain .NET wouldn't be so difficult.
thanks for the response ,
.NET based logic derivation seems like take some time , that's why i approached this way , is there any other way to achieve connected entity selection ? that would be better for me , can you share your thought on this ?
Here's a quick and dirty you can start from.
static ObjectIdCollection FastSel(Editor ed, ObjectId sourceId)
{
var ids = new ObjectIdCollection { sourceId };
var db = sourceId.Database;
using (var tr = db.TransactionManager.StartOpenCloseTransaction())
{
var sourceEntity = (Entity)tr.GetObject(sourceId, OpenMode.ForWrite);
var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead);
var points = new Point3dCollection();
using (var view = ed.GetCurrentView())
{
var plane = new Plane(view.Target, view.ViewDirection);
foreach (ObjectId id in curSpace)
{
var entity = (Entity)tr.GetObject(id, OpenMode.ForRead);
points.Clear();
sourceEntity.IntersectWith(entity, Intersect.OnBothOperands, plane, points, IntPtr.Zero, IntPtr.Zero);
if (0 < points.Count)
{
ids.Add(entity.ObjectId);
}
}
}
}
return ids;
}
Thanks gile , surely this will help me ,in this case i have to replicate same logic behind FASTSEL command in .NET, i have analyzed fastsel.lsp file which is available in express folder but am not familiar with lisp ,so i could not understand the logic which is wrote behind the FASTSEL , can you give me brief description what are the logic steps followed for each entity ?
we have to do recursion until all the touched object added in list , if i am wrong correct me _gile
@mttlp a écrit :
how can i make the above code to select all like fastsel
[CommandMethod("TEST")]
public void Test()
{
var ed = Application.DocumentManager.MdiActiveDocument.Editor;
var per = ed.GetEntity("\nSelect touch entity: ");
if (per.Status != PromptStatus.OK)
return;
var ids = FastSel(ed, per.ObjectId);
var array = new ObjectId[ids.Count];
ids.CopyTo(array, 0);
ed.SetImpliedSelection(array);
}
Hi ,
Here all the DB entities are looping for single entity, when it is comes in large models , lot of time will take here , instead of using intersect i have used SelectFence in autocad api , it gives exact result for line entity , it does not work for ARC's , is there any efficient way to achieve the connected element identification in AutoCAD ?
Can't find what you're looking for? Ask the community or share your knowledge.