selectionset in .net

Discussion in 'AutoCAD' started by isaacmor, Mar 10, 2005.

  1. isaacmor

    isaacmor Guest

    I am using .net in autocad2005 and i need some code examples.

    Dim FilterType(0) As Integer
    Dim FilterData(0) As Object
    FilterType(0) = 0
    FilterData(0) = "Circle"
    Dim ss As AutoCAD.AcadSelectionSet
    Try
    ss = m_AcadApp.ActiveDocument.SelectionSets.Add("yyy")
    Catch ex As Exception
    ss = m_AcadApp.ActiveDocument.SelectionSets.Item("yyy")
    End Try
    ss.Select(AcSelect.acSelectionSetAll, , , FilterType, FilterData)

    the Exception is on the select methode

    the Exception details:


    An unhandled exception of type 'System.ArgumentException' occurred in VbDotNetisaac.exe
    Additional information: Invalid argument FilterType in Select

    How I use the FilterType and the FilterData objects?
    thanks
     
    isaacmor, Mar 10, 2005
    #1
  2. FilterData should always be dimmed as Variant.
    In your example, "Circle" is not an object but a string. It
    doesn't though, you still have to dim your FilterData as Variant.

    Arnaud
     
    Arnaud Lesauvage, Mar 10, 2005
    #2
  3. There is no Variant data type in .NET.
     
    Frank Oquendo, Mar 10, 2005
    #3
  4. Your subscripting is off. The zeros in your Dim statements should be
    ones. An easy way to avoid subscripting errors like this is to populate
    the array while declaring it:

    Dim FilterType As Integer[] = {0};
    Dim FilterData As Object[] = {"CIRCLE"};
     
    Frank Oquendo, Mar 10, 2005
    #4
  5. isaacmor

    MP Guest

    Hi Frank,
    Does that mean arrays are 1 based in .net?
    I thought the integer type had to be called something else in .net???

     
    MP, Mar 10, 2005
    #5
  6. No. The number used to declare the size of an array is the number of
    elements in the array, not their ordinals.
    You're right. In .NET we have to use System.Int16 while Integer is
    System.Int32. Use Short instead:

    Dim FilterType As Short[] = {0};
     
    Frank Oquendo, Mar 10, 2005
    #6
  7. sorry to contradict, within vb.net there is no 'Variant' available, 'Object' is ok, what i see in your code is that between vb6 and vb.net the
    datatype 'Integer' is different (16bit <<>> 32bit). so use:

    Dim FilterType(0) as Int16

    - alfred -
     
    Alfred NESWADBA, Mar 10, 2005
    #7
  8. isaacmor

    MP Guest

    so why is it not
    Dim FilterType As Short[1] = {0};

    I guess assigning the array automatically sizes it?

    so for a 3 element array would it be?
    Dim FilterType As Short[] = {0,0,0};
     
    MP, Mar 10, 2005
    #8
  9. That is correct.
    Yep. Or if you prefer:

    Dim FilterType[] as New Short[3]
    FilterType[0] = 1
    FilterType[1] = 2
    FilterType[2] = 3
     
    Frank Oquendo, Mar 10, 2005
    #9
  10. isaacmor

    fantum Guest

    Your subscripting is off. The zeros in your Dim statements should be ones.

    Please choose a single language per example (or at least per line of code) to avoid confusing others and yourself.
     
    fantum, Mar 11, 2005
    #10
  11. Your comments are both rude and unhelpful. If there is an error in what
    I posted, please correct it. Preferably without condescension.
     
    Frank Oquendo, Mar 11, 2005
    #11
  12. What fantum noted without actually explaining is that the square
    brackets I used should be parens.

    Sorry about that. I very rarely use VB.NET.
     
    Frank Oquendo, Mar 11, 2005
    #12
  13. isaacmor

    fantum Guest

    My apologies. You might also note that, for VB, the semicolon is a syntax error and that your statements regarding the numbers used in array declaration, while correct for C#, are incorrect for VB (unless you happen to be using quite an old beta).
     
    fantum, Mar 11, 2005
    #13
  14. I overlooked the semicolon too. As for arrays in VB.NET, I just tried it
    out and you're right.

    'Dim x(n) As y' creates an array of n + 1 elements while C# creates an
    array of n elements. Thanks for the heads up.
     
    Frank Oquendo, Mar 11, 2005
    #14
  15. isaacmor

    fantum Guest

    Certainly. And again, sorry for my earlier tone. I can only plead a short temper due a very long week.
     
    fantum, Mar 11, 2005
    #15
  16. isaacmor

    isaacmor Guest

    frank
    THANK'S
     
    isaacmor, Mar 13, 2005
    #16
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.