VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SelectOnScreen VBA

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
2520 Views, 7 Replies

SelectOnScreen VBA

Hello,
with VBA i use the SelectOnScreen method
Is it possible to know the two points clicked if the user select with "window"
or "crossing"?
Thank you
--
Bernard Flavignard
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

Hi Bernard

Load the code from this link:
http://www.apress.com/book/supplementDownload.html?bID=242&sID=1577

Fatty

~'J'~
Message 3 of 8
Anonymous
in reply to: Anonymous

Thank Fatty,
I found this

Public Sub TestSelectOnScreen()
Dim objSS As AcadSelectionSet

On Error GoTo Done
With ThisDrawing.Utility

'' create a new selectionset
Set objSS = ThisDrawing.SelectionSets.Add("TestSelectOnScreen")

'' let user select entities interactively
objSS.SelectOnScreen

-----------------------------
Here i want to know the 2 points clicked if user choose Windows or crossing by
clicking only a rectangle
----------------------------
'' highlight the selected entities
objSS.Highlight True

'' pause for the user
.Prompt vbCr & objSS.Count & " entities selected"
.GetString False, vbLf & "Enter to continue "

'' dehighlight the entities
objSS.Highlight False

End With

Done:

'' if the selection was created, delete it
If Not objSS Is Nothing Then
objSS.Delete
End If
End Sub


--
Bernard Flavignard

a écrit dans le message de news: 5147727@discussion.autodesk.com...
Hi Bernard

Load the code from this link:
http://www.apress.com/book/supplementDownload.html?bID=242&sID=1577

Fatty

~'J'~
Message 4 of 8
Anonymous
in reply to: Anonymous

Happy to help

Cheers 🙂

Fatty

~'J'~
Message 5 of 8
Anonymous
in reply to: Anonymous

I am French, and i dont understand all you say in english....
My question in the code.... i have the book.

'' let user select entities interactively
objSS.SelectOnScreen

-----------------------------
Here i want to know the 2 points clicked if user choose Windows or crossing by
clicking only a rectangle
----------------------------


--
Bernard Flavignard

a écrit dans le message de news: 5147862@discussion.autodesk.com...
Happy to help

Cheers 🙂

Fatty

~'J'~
Message 6 of 8
Anonymous
in reply to: Anonymous

Hi Bernard,
Sorry for my inattention...
I shall help you tomorrow, now is too later for me
Btw, I am from Russia

Have a good one

~'J'~
Message 7 of 8
Anonymous
in reply to: Anonymous

Okay, see this example but very quick and dirty...

[code]
Sub Example_SelectBy_Window()
' This example adds members to a selection set by window
Dim objnewss As AcadSelectionSet
Dim objSelColl As AcadSelectionSets
Dim fstCorner, sndCorner As Variant
With ThisDrawing
Set objSelColl = .SelectionSets
For Each objnewss In objSelColl
If objnewss.Name = "$TestSset$" Then
objSelColl.Item("$TestSset$").Delete
Exit For
End If
Next objnewss
Set objnewss = objSelColl.Add("$TestSset$")
fstCorner = .Utility.GetPoint(, "Enter first corner of window")
sndCorner = .Utility.GetCorner(fstCorner, "Enter opposite corner of window")

Dim mode As Integer

mode = acSelectionSetWindow
' another mode you can use:
'acSelectionSetCrossing
objnewss.Select mode, fstCorner, sndCorner
objnewss.Highlight True

'' pause for the user
.Utility.Prompt vbCr & objnewss.Count & " entities selected"
.Utility.GetString False, vbLf & "Enter to continue "

'' dehighlight the entities
objnewss.Highlight False
End With


MsgBox ("First corner : " & vbCrLf & _
"X: " & CStr(fstCorner(0)) & vbCr & _
"Y: " & CStr(fstCorner(1)) & vbCr & _
"Z: " & CStr(fstCorner(2)))
MsgBox ("Second corner : " & vbCrLf & _
"X: " & CStr(sndCorner(0)) & vbCr & _
"Y: " & CStr(sndCorner(1)) & vbCr & _
"Z: " & CStr(sndCorner(2)))

End Sub

Fatty

~'J'~
[/code] Message was edited by: Fatty
Message 8 of 8
Anonymous
in reply to: Anonymous

Fatty,
Excuse me, but it is not what i want.
I want to program only

objSS.SelectOnScreen

-----------------------------
Here i want to know the 2 points clicked if user choose Windows or crossing by
clicking only a rectangle, not choose W ot C
----------------------------

I do not want

fstCorner = .Utility.GetPoint(, "Enter first corner of window")
sndCorner = .Utility.GetCorner(fstCorner, "Enter opposite corner of window")

Sorry
--
Bernard Flavignard

a écrit dans le message de news: 5148003@discussion.autodesk.com...
Okay, see this example but very quick and dirty...

[code]
Sub Example_SelectBy_Window()
' This example adds members to a selection set by window
Dim objnewss As AcadSelectionSet
Dim objSelColl As AcadSelectionSets
Dim fstCorner, sndCorner As Variant
With ThisDrawing
Set objSelColl = .SelectionSets
For Each objnewss In objSelColl
If objnewss.Name = "$TestSset$" Then
objSelColl.Item("$TestSset$").Delete
Exit For
End If
Next objnewss
Set objnewss = objSelColl.Add("$TestSset$")
fstCorner = .Utility.GetPoint(, "Enter first corner of window")
sndCorner = .Utility.GetCorner(fstCorner, "Enter opposite corner of window")

Dim mode As Integer

mode = acSelectionSetWindow
' another mode you can use:
'acSelectionSetCrossing
objnewss.Select mode, fstCorner, sndCorner
objnewss.Highlight True

'' pause for the user
.Utility.Prompt vbCr & objnewss.Count & " entities selected"
.Utility.GetString False, vbLf & "Enter to continue "

'' dehighlight the entities
objnewss.Highlight False
End With


MsgBox ("First corner : " & vbCrLf & _
"X: " & CStr(fstCorner(0)) & vbCr & _
"Y: " & CStr(fstCorner(1)) & vbCr & _
"Z: " & CStr(fstCorner(2)))
MsgBox ("Second corner : " & vbCrLf & _
"X: " & CStr(sndCorner(0)) & vbCr & _
"Y: " & CStr(sndCorner(1)) & vbCr & _
"Z: " & CStr(sndCorner(2)))

End Sub

Fatty

~'J'~
[/code]

Message was edited by: Fatty

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost