Trying to use a autocad command with VBA and selectionSet

Discussion in 'AutoCAD' started by Torre, Apr 8, 2004.

  1. Torre

    Torre Guest

    I am trying to to trim objects with the autocad map command maptrim with VBA. My problem is to access the selection set with maptrim. I dont know how I should make one selection active so i can use it in the command. This is my code, so far:

    Private Sub CommandButton1_Click()
    Me.Hide
    Dim FilterType(0) As Integer
    Dim FilterData(0) As Variant

    Dim sset As AcadSelectionSet
    Dim ent As AcadEntity
    Dim name As String
    FilterType(0) = 8
    FilterData(0) = "Building"

    ThisDrawing.ActiveSelectionSet.Clear

    Set sset = ThisDrawing.SelectionSets.Add("ss25")
    'Set sset = ThisDrawing.SelectionSets.Add("new_selset")
    Set sset = ThisDrawing.ActiveSelectionSet
    sset.SelectOnScreen FilterType, FilterData

    For Each ent In sset
    Debug.Print ent.ObjectName
    SendToCommandPrompt "._CMDDIA" & vbCr & "0"
    SendToCommandPrompt "._maptrim" & vbCr & "S" & vbCr & "L" ; here is the problem
    SendToCommandPrompt "Y"
    SendToCommandPrompt "0"
    SendToCommandPrompt "N"
    SendToCommandPrompt "I"
    SendToCommandPrompt "Y"
    SendToCommandPrompt "Y"
    SendToCommandPrompt "I"
    SendToCommandPrompt "._CMDDIA" & vbCr & "1"
    Next

    sset.Clear
    sset.Delete

    MsgBox "completed"
    Me.Show
    End Sub

    Can anybody help me?

    /Torkel R
     
    Torre, Apr 8, 2004
    #1
  2. Torre

    James Murphy Guest

    A few things that I see are:
    Shouldn't it be "SendCommand" instead of "SendToCommandPrompt"?
    Using the Select method for MapTrim requires a boundry to passed to it
    first, then the "Selection Set", and the sel-set as a whole not each item
    in it.
    Look at doing it in Vlisp it's a lot easier since the maptools are easier to
    get to than in VBA.

    Murph


    VBA. My problem is to access the selection set with maptrim. I dont know how
    I should make one selection active so i can use it in the command. This is
    my code, so far:
     
    James Murphy, Apr 9, 2004
    #2
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.