.NET

Reply
Active Contributor
Posts: 27
Registered: ‎09-02-2013
Message 1 of 4 (171 Views)
Accepted Solution

Selection set by single point .

171 Views, 3 Replies
09-02-2013 04:43 AM

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.

*Expert Elite*
Hallex
Posts: 1,561
Registered: ‎10-08-2008
Message 2 of 4 (163 Views)

Re: Selection set by single point .

09-02-2013 07:18 AM 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
Active Contributor
Posts: 27
Registered: ‎09-02-2013
Message 3 of 4 (154 Views)

Re: Selection set by single point .

09-02-2013 08:27 AM 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.
Valued Contributor
FRFR1426
Posts: 70
Registered: ‎04-05-2012
Message 4 of 4 (105 Views)

Re: Selection set by single point .

09-04-2013 04:56 AM in reply to: aliensinearth

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community