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

Selection set by single point .

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
aliensinearth
440 Views, 3 Replies

Selection set by single point .

I am using following lisp code to select line object by single point.

(setq pt (getpoint "\nPick a point"))
(setq ss (ssget pt))

 

What is the .Net equivalent to achieve this? (select object by a single point I provide)

Thanks in advance.

3 REPLIES 3
Message 2 of 4
Hallex
in reply to: aliensinearth

Try this code snip:

                   Dim ppo As New PromptPointOptions(vbLf & "Pick a Point: ")
                    Dim ppr As PromptPointResult
                    ppr = ed.GetPoint(ppo)
                    If ppr.Status <> PromptStatus.OK Then
                        ed.WriteMessage(vbCrLf & "wrong point specification!")
                        Exit Sub
                    End If
                    Dim p As Point3d = ppr.Value
                    '------------------------------------------------------------''
                    Dim vd As Vector3d = New Vector3d(1e-4, 1e-4, 1e-4) '<--  dicrease a fuzz to suit
                    Dim pMin As Point3d = p - vd
                    Dim pMax As Point3d = p + vd              
                    Dim tvs() As TypedValue = New TypedValue() { New TypedValue(0, "line")}
                    Dim points As Point3dCollection = New Point3dCollection
                    points.Add(pMin)
                    points.Add(pMax)
                    Dim sf As SelectionFilter = New SelectionFilter(tvs)
                    Dim sres As PromptSelectionResult = ed.SelectFence(points, sf)
                    If sres.Status <> PromptStatus.OK Then
                        ed.WriteMessage("\nWrong selection!")
                        Return
                    End If

                    If sres.Value.Count = 0 Then
                        ed.WriteMessage("\nNothing selected!")
                        Return
                    End If
                    '' cast entity as Line
                    Dim eid As ObjectId = sres.Value.GetObjectIds(0)
                    Dim ent As Entity = TryCast(tr.GetObject(eid, OpenMode.ForRead), Entity)
                    ''-----------------------------------------------------------''
                    Dim ln As Line = TryCast(ent, Line)
                    If ln IsNot Nothing Then
                        ed.WriteMessage(vbLf + "{0},{1},{2}", ln.StartPoint.X, ln.StartPoint.Y, ln.StartPoint.Z)
                    End If

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 4
aliensinearth
in reply to: Hallex

Thank you very much Hallex. It is working fine.
But one small problem is that, If two objects lie in the same point, Lisp code selects the top object in display order. But .Net is selecting both objects. It's OK i will manage.
Thanks once again.
Message 4 of 4
FRFR1426
in reply to: aliensinearth

You can also look at this post: http://through-the-interface.typepad.com/through_the_interface/2006/11/two_methods_for.html

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr

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