get entity inside an xref given a point

get entity inside an xref given a point

Anonymous
Not applicable
2,541 Views
10 Replies
Message 1 of 11

get entity inside an xref given a point

Anonymous
Not applicable
hi. is there any way to get the entity inside an xref given a point? im using vb.net thanks... Edited by: a7v1n on Apr 8, 2010 6:16 AM
0 Likes
2,542 Views
10 Replies
Replies (10)
Message 2 of 11

_gile
Consultant
Consultant
Hi,

Look at the NonInteractivePickPoint and UseNonInteractivePickPoint properties of the PromptNestedEntityOptions class.


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 11

Anonymous
Not applicable
could you post some code pls? Thanks...
0 Likes
Message 4 of 11

_gile
Consultant
Consultant
Here's a C# sample

{code}private ObjectId GetNestedEntityByPoint(Point3d pt)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptNestedEntityOptions pneo = new PromptNestedEntityOptions("");
pneo.NonInteractivePickPoint = pt;
pneo.UseNonInteractivePickPoint = true;
PromptNestedEntityResult pner = ed.GetNestedEntity(pneo);
return pner.ObjectId;
}{code}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 11

Anonymous
Not applicable

Help needed - Using the above code, when a point is selected in the black area on the drawing which means nothing is selected, the autocad keeps running infinitely in a loop like thing.

Is there a way to check when there is no selection made for a nested entity. Like when  nothing is selected do something.

I am using vb.net

0 Likes
Message 6 of 11

Anonymous
Not applicable

I have or seen something similar. When I get more time I will try to find it

 

For now this goes in the oppisite direction but might help.

The basic idea is when you are in paperspace and notice the xref is missing something or you want to add something. Instead of opening the xref or switching to model or editing in place the xref. You can just draw on top of the viewport then send it to the xref just as it appears.

 

Here is the link and alot of other great info and users http://www.theswamp.org/index.php?topic=34590.0

 

0 Likes
Message 7 of 11

Anonymous
Not applicable

thanks for the reply..

 

But I want to check if the selected point is on a nested entity not an entity.

For entity we can do addallowedclass(viewport) but how can we do something similar to that for a nested entity.?

 

i have the code i am using to get nested entity at selected point.

 

 

Dim pneo As PromptNestedEntityOptions

 

 

 

pneo =NewPromptNestedEntityOptions("")

pneo.NonInteractivePickPoint = selectedpoint

 pneo.UseNonInteractivePickPoint =True

 

 

Dim psubent As Entity = acTrans.GetObject(acDoc.Editor.GetNestedEntity(pneo).ObjectId, OpenMode.ForRead)

it hangs up in the above line where i am getting the objectid.

anything i am doing wrong?

 

0 Likes
Message 8 of 11

kerry_w_brown
Advisor
Advisor

 

What is the owner of the entity ?? ... may help decide

ie is the container BlockTable ModelSpace, Paperspace or a block


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 9 of 11

Anonymous
Not applicable

Thanks for the reply..

I am unable to get the owner ID of the nested entity. Since, it hangs up at getting the object ID itself, it does not go till the point I am able to get the nested entity.

  

Please, find my whole code is as below:

  

Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

 Dim acCurDb As Database = acDoc.Database

  

While (True)

 

Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()

 

' Open the Block table record for read

  Dim acBlkTbl As BlockTable

 acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)

 

 '' Open the Block table record Model space for write

  Dim acBlkTblRec As BlockTableRecord

 acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

 

 Application.SetSystemVariable("OSMODE", 512)

 Dim acnsprompt As PromptPointResult = acDoc.Editor.GetPoint(vbCrLf & "Select APN or <exit>: ")

 

If acnsprompt.Status = PromptStatus.OK And Not IsNothing(acnsprompt.Value) Then

  Dim pneo As PromptNestedEntityOptions

 pneo =New PromptNestedEntityOptions("")

 pneo.NonInteractivePickPoint = acnsprompt.Value

 pneo.UseNonInteractivePickPoint =True

 pneo.AllowNone =True

 

 If acDoc.Editor.GetNestedEntity(pneo).ObjectId = ObjectId.Null Or Not IsNothing(acDoc.Editor.GetNestedEntity(pneo).ObjectId) Or Not IsDBNull(acDoc.Editor.GetNestedEntity(pneo).ObjectId) Then

 

 Dim psubent As Entity = acTrans.GetObject(acDoc.Editor.GetNestedEntity(pneo).ObjectId,OpenMode.ForRead)

If psubent.GetRXClass.Name.ToString = "AcDbText" Then

 If psubent.Layer.Contains("APN") Then

  

Dim txt As DBText = DirectCast(psubent, Entity)

 End If

 End If

 psubent.Dispose()

 End If

 pneo =Nothing

end if

end using

end while

 

0 Likes
Message 10 of 11

Anonymous
Not applicable
Please see the below modified code is suitable for you. Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database While (True) Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() Dim acBlkTbl As BlockTable acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) Dim acBlkTblRec As BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite) Application.SetSystemVariable("OSMODE", 512) Dim prent As PromptEntityOptions = New PromptEntityOptions("Specify Entity:") prent.SetRejectMessage("Only BlockReferences Allowed!") prent.AddAllowedClass(GetType(BlockReference), True) Dim rsent As PromptEntityResult = acDoc.Editor.GetEntity(prent) If Not rsent.Status = PromptStatus.OK Then Return Dim pneo As PromptNestedEntityOptions pneo = New PromptNestedEntityOptions("") pneo.NonInteractivePickPoint = rsent.PickedPoint pneo.UseNonInteractivePickPoint = True pneo.AllowNone = True If Not acDoc.Editor.GetNestedEntity(pneo).ObjectId = ObjectId.Null Or IsNothing(acDoc.Editor.GetNestedEntity(pneo).ObjectId) Or IsDBNull(acDoc.Editor.GetNestedEntity(pneo).ObjectId) Then Dim psubent As Entity = acTrans.GetObject(acDoc.Editor.GetNestedEntity(pneo).ObjectId, OpenMode.ForRead) If psubent.GetRXClass.Name.ToString = "AcDbText" Then If psubent.Layer.Contains("APN") Then Dim txt As DBText = DirectCast(psubent, Entity) End If End If psubent.Dispose() End If pneo = Nothing End Using End While
0 Likes
Message 11 of 11

Anonymous
Not applicable

Thanks for the reply.

0 Likes