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

get entity inside an xref given a point

10 REPLIES 10
Reply
Message 1 of 11
a7v1n
2337 Views, 10 Replies

get entity inside an xref given a point

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
10 REPLIES 10
Message 2 of 11
_gile
in reply to: a7v1n

Hi,

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


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 11
a7v1n
in reply to: a7v1n

could you post some code pls? Thanks...
Message 4 of 11
_gile
in reply to: a7v1n

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
in reply to: _gile

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

Message 6 of 11
Anonymous
in reply to: Anonymous

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

 

Message 7 of 11
Anonymous
in reply to: Anonymous

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?

 

Message 8 of 11
kdub_nz
in reply to: Anonymous

 

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

ie is the container BlockTable ModelSpace, Paperspace or a block


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 9 of 11
Anonymous
in reply to: kdub_nz

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

 

Message 10 of 11
Anonymous
in reply to: a7v1n

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
Message 11 of 11
Anonymous
in reply to: Anonymous

Thanks for the reply.

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