The problem is that a user needs to select a block the select a point on that block where he wants a leader to be placed. I need to be able to tell how far from the block insertion point is the point where he wants the leader to be placed regardless of the rotation of the block or the orientation of the UCS.
I have been chasing my tail on this for two days and I just don't know how to do this. Anyone got a suggestion? All help is appreciated.
Sonny
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Hi,
You simply need to get the BlockReference.Position which is always WCS defined and transform the point returned by PromptPointResult.Value to WCS coordinates because it's always UCS defined.
var ed = Application.DocumentManager.MdiActiveDocument.Editor; var peo = new PromptEntityOptions("\nSelect block: "); peo.SetRejectMessage("\nMust be a block."); peo.AddAllowedClass(typeof(BlockReference), true); var per = ed.GetEntity(peo); if (per.Status == PromptStatus.OK) { var ppr = ed.GetPoint("\nSpecify a point: "); if (ppr.Status == PromptStatus.OK) { dynamic br = per.ObjectId; var position = br.Position; var point = ppr.Value.TransformBy(ed.CurrentUserCoordinateSystem); var distance = point.DistanceTo(position); ed.WriteMessage("\nDistance = {0}", distance); } }
Nice example Gilles.
Sonny,
Because the example uses dynamic ;
Important: When working with DLR and C#, you will need to reference the Microsoft.CSharp library.
// Called Kerry in my other life.
Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.
class keyThumper<T> : Lazy<T>; another Swamper
Thanks _kdub,
I will take some time out to read through the article in the link you provided.
sonny
Can't find what you're looking for? Ask the community or share your knowledge.