Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

AutoCAD VBA rubber banding

Status
Not open for further replies.

jrice174

Civil/Environmental
Nov 8, 2004
129
In a VBA program when I have the user select an area on the screen, I call the GetUserPoint twice (to get both points) and then call the SelectByPoints sub. Doing this, the user does not have rubber banding as they move the mouse from their first selection point to the second. It seems as if it's not working for the user if they don't see the familar rubber banding. How do I get the rubber banding outline to show up? My code is shown below.

Public Sub GetUserPoint()
PointPicked = True
With ThisDrawing.Utility
On Error GoTo NoInput
varPick = .GetPoint(, vbCr & "Pick a point: ")
.Prompt vbCr & varPick(0) & "," & varPick(1)
On Error GoTo NoInput
End With
Exit Sub
NoInput:
PointPicked = False
End Sub


and


Public Sub SelectByPoints()
On Error Resume Next
ThisDrawing.SelectionSets("TEMP").Delete
Set objSS = ThisDrawing.SelectionSets.Add("TEMP")
''''objSS.Select 1, Pt1, Pt2, intCodes, varCodeValues ' 5 = all, 1 = use Pt1 and Pt2
objSS.Select 1, Pt1, Pt2
End Sub
 
Replies continue below

Recommended for you

You've already got the code 95% written.. :)

All you have to do is use Pt1 in a second .getpoint statement, you've been passing the option by..

Pt2 = .GetPoint(Pt1, vbCr & "Pick second point: ")

Tim Grote - The Irrigation Engineers.
 
That's better, but I'm getting a line from the first picked point to the cursor. What I was hoping for is a rectangle like what you get if you invoke the ERASE command.
 
Ahh... I see what you're trying to do now.

What might be handy for you is to let the user select however they like. That method is simply (.selectonscreen) you user will then be able to select individual entities, or window, or window polygon, etc. You can even apply filters if you like. It looks something like this:

'==============================================================================
'Return a selectionset of Sprinklers
'==============================================================================
Public Function GetSprinklers() As AcadSelectionSet
Dim objSetSprinklers As AcadSelectionSet
Dim GroupCode(0 To 1) As Integer
Dim DataValue(0 To 1) As Variant
Dim FilterType As Variant
Dim FilterData As Variant
'------------------------------------------------------

Set objSetSprinklers = MakeSelectionSet("02810sprinklerss")
GroupCode(0) = 0: DataValue(0) = "Insert"
GroupCode(1) = 8: DataValue(1) = "02810-sprinkler"
FilterType = GroupCode: FilterData = DataValue
ThisDrawing.Utility.Prompt "Select Sprinklers:"
objSetSprinklers.SelectOnScreen FilterType, FilterData
Set GetSprinklers = objSetSprinklers

End Function


Tim Grote - The Irrigation Engineers.
 
BEAUTIFUL!! That did it. That's exactly what i want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor