Multi Select and Addition

Discussion in 'AutoCAD' started by stck2mlon, Feb 22, 2005.

  1. stck2mlon

    stck2mlon Guest

    How could I edit this so that I could select multiple lines and polylines and get the sum of them into entLength?

    Private Sub cmdSelect_Click()

    'Declare Variables
    Dim returnobj As Object
    Dim entbasepnt As Variant
    Dim entLength As String

    frmLineLength.txtLineLength.Text = ""

    Me.Hide
    ThisDrawing.Utility.GetEntity returnobj, entbasepnt, "Select Streets: "
    If TypeOf returnobj Is AcadLWPolyline Or acLine Then
    entLength = CStr(returnobj.Length)
    Else
    ThisDrawing.Utility.Prompt returnobj.ObjectName & " selected. Please select a line:"
    AcadApplication.Update
    End If

    entLength = ThisDrawing.Utility.RealToString(entLength, acArchitectural, 4)
    Me.txtLineLength.Text = entLength
    Me.Show
    End Sub

    Thanks a ton everyone!
     
    stck2mlon, Feb 22, 2005
    #1
  2. stck2mlon

    Oberer Guest

    Still working on the streets project stck2mlon? It must be moving right along :)

    You'll want to create a selection set using filters and use a for each loop to calc your total...



    Code:
    Public Sub test()
    Dim oSelSet As AcadSelectionSet
    Dim oEnt As AcadEntity
    Dim grpCode(0) As Integer
    Dim dataVal(0) As Variant
    Dim dblLength As Double
    
    'start an undo mark in the DB
    ThisDrawing.StartUndoMark
    'create a new selection set object
    Set oSelSet = vbdPowerSet("SS01")
    
    ' Build a selection set of group codes and values to filter for: Text or Mtext.
    grpCode(0) = 0
    dataVal(0) = "LINE,POLYLINE,LWPOLYLINE"
    
    'prompt for user to select text
    oSelSet.SelectOnScreen grpCode, dataVal
    
    For Each oEnt In oSelSet
    If TypeOf oEnt Is AcadLine Then
    dblLength = dblLength + oEnt.length
    ElseIf TypeOf oEnt Is AcadPolyline Or TypeOf oEnt Is AcadLWPolyline Then
    'dblLength = <GET/CALC POLYLINE LENGTH HERE>
    'shouldn't be here if we're using a filtered sel set
    Else
    MsgBox "Can't handle: " & oEnt.ObjectName
    End If
    
    Next
    
    Debug.Print dblLength
    
    End Sub
    
     
    Oberer, Feb 23, 2005
    #2
  3. stck2mlon

    stck2mlon Guest

    Thanks a ton. Your suggestions have made this project what it is and I thank you for being very clear and helping out.
     
    stck2mlon, Feb 23, 2005
    #3
  4. stck2mlon

    Oberer Guest

    stck2mlon ,
    As I've mentioned before, there has been plenty of help thrown my way as well. Always happy to give back a little...

    "have made this project what it is"
    I can also appreciate the sense of accomplishment when putting together these utilities :)
     
    Oberer, Feb 23, 2005
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.