Passing SSET item to VPORTS for SendCommand

Discussion in 'AutoCAD' started by sharps4065, Aug 24, 2004.

  1. sharps4065

    sharps4065 Guest

    I'm trying to code the creation of a clipped VP. I need to pass the first object in the selection set to the vports command. So far my code is as follows:

    Dim ssetObj As AcadSelectionSet
    On Error Resume Next
    ThisDrawing.SelectionSets.Item("VPClipSSET").Delete
    Set ssetObj = ThisDrawing.SelectionSets.Add("VPClipSSET")
    On Error GoTo 0
    ' Add objects to a selection set by prompting user to select on the screen
    ssetObj.SelectOnScreen
    ThisDrawing.SendCommand "-vports" & vbCr & "o" & vbCr & ssetObj.Item(0) & vbCr & vbCr

    This errors "the object doesn't support the property or method". I've tried "previous" but this doesn't work and "last" works - but using the last object drawn which may not be the clipping object wanted!

    Any suggestions on passing items from a selection set?

    Clive Taylor
    IT manager
    Design Services
    WCC
     
    sharps4065, Aug 24, 2004
    #1
  2. sharps4065

    SpeedCAD Guest

    Hi...

    You test the next:

    ThisDrawing.SendCommand "-vports" & vbCr & "o" & vbCr

    And the user must select the object in screen. Next you use:

    ssetObj.acSelectionSetPrevious

    Un saludo de SpeedCAD... :D
    CHILE
    FORO: http://www.hispacad.com/foro
     
    SpeedCAD, Aug 24, 2004
    #2
  3. sharps4065

    sharps4065 Guest

    Hi

    Thanks for responding. Unfortunately I don't seem to be able to make this suggestion work. Could you actually write the lines of code as you intend them to be. Thanks.

    Regards
    Clive
     
    sharps4065, Aug 24, 2004
    #3
  4. sharps4065

    SpeedCAD Guest

    Hi...

    Is it the same at your code, but in reverse:

    Dim ssetObj As AcadSelectionSet
    On Error Resume Next
    ThisDrawing.SelectionSets.Item("VPClipSSET").Delete
    Set ssetObj = ThisDrawing.SelectionSets.Add("VPClipSSET")
    On Error GoTo 0
    ThisDrawing.SendCommand "-vports" & vbCr & "o" & vbCr
    ssetObj.acSelectionSetPrevious

    Un saludo de SpeedCAD... :D
    CHILE
    foro:http://www.hispacad.com
     
    SpeedCAD, Aug 24, 2004
    #4
  5. sharps4065

    sharps4065 Guest

    Hi

    That's what I used but I get an "Object doesn't support this property or method" on the ssetObj.acSelectionSetPrevious line. if I change the line to ssetObj.select acSelectionSetPrevious there's no error but the code continues to the end leaving the SendCommand still waiting for a selection.

    Regards
    Clive
     
    sharps4065, Aug 24, 2004
    #5
  6. sharps4065

    Ed Jobe Guest

    Use this function to pass an object to the command line.

    Public Function Ent2LspEnt(entObj As AcadEntity) As String
    'Designed to work with SendCommand, which can't pass objects.
    'This gets an objects handle and converts it to a string
    'of lisp commands that returns an entity name when run in SendCommand.
    Dim entHandle As String

    entHandle = entObj.Handle
    Ent2LspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
    End Function

    Then you just need:
    ThisDrawing.SendCommand "-vports" & vbCr & "o" & Ent2LspEnt (ssObj) & vbCr
     
    Ed Jobe, Aug 24, 2004
    #6
  7. sharps4065

    sharps4065 Guest

    Thanks Ed, I owe you one.

    Cheers
    Clive
     
    sharps4065, Aug 25, 2004
    #7
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.