Extract information form object

Discussion in 'AutoCAD' started by jorgematheus, Jul 5, 2004.

  1. jorgematheus

    jorgematheus Guest

    Hi
    I'm trying to get information from this object

    Command: (VLAX-DUMP-OBJECT LODRIVES T)
    ; ISWbemObjectSet: A collection of Classes or Instances
    ; Property values:
    ; Count (RO) = 2
    ; Security_ (RO) = #<VLA-OBJECT ISWbemSecurity 003edf30>
    ; Methods supported:
    ; Item (2)
    T

    I have tryied this:

    Command: (foreach item lodrives (vlax-get-property item 'SerialNumber))
    ; error: bad argument type: consp #<VLA-OBJECT ISWbemObjectSet 003eded0>

    or this:

    Command: (VLA-ITEM LODRIVES 1 "SerialNumber")
    ; error: too few actual parameters

    and this:

    Command: (vlax-invoke-method lodrives "Item" 1 )
    ; error: too few actual parameters

    Can someone help me out here??

    Thank In Advance

    Jorge Matheus
    Caracas Venezuela
     
    jorgematheus, Jul 5, 2004
    #1
  2. jorgematheus

    Jürg Menzi Guest

    Hi Jorge
    You can't step through a collection by 'foreach' - use vlax-for instead.
    'vla-item' has only 2 parameters: (vla-item Collection Index)

    Cheers
     
    Jürg Menzi, Jul 5, 2004
    #2
  3. Jorge,

    maybe this will work?

    (vlax-map-Collection LODRIVES
    '(lambda (o)
    (VLAX-DUMP-OBJECT o T)
    )
    )


    Peter
     
    petersciganek, Jul 5, 2004
    #3
  4. jorgematheus

    Jürg Menzi Guest

    And...

    AFAIK 'ISWbemObject' has no 'SerialNumber' property...

    Cheers
     
    Jürg Menzi, Jul 5, 2004
    #4
  5. jorgematheus

    jorgematheus Guest

    Thank for yours quick answers

    I'm little lost in here, can some one explain a little bit more for me?

    i'm translating a code from Visual basic and Visual fox.

    i query WIN32_PHYSICALMEDIA and got a collection, them
    with Item, i extrac SerialNumber from each item.

    i use lcSerial = loDrive.SerialNumber to extract the value in visual Basic or Visual FOX.

    In Lisp i got the colletion but i can't extract the item i have query.

    When i send (vlax-invoke-method lodrives "Item" 1)
    i got this error
    ; error: too few actual parameters

    Is there a way to do exact what VIsual Basic o r Visual FOx do using Lisp.

    Thank again
     
    jorgematheus, Jul 5, 2004
    #5
  6. Jorge -

    Although I am not familiar with the ISWbemObject* I assume that you can use vlax-map-collection to iterate through each item in the collection - something like this:

    (defun getSerialNumbers (LODRIVES / ret)
    (vlax-map-Collection LODRIVES
    '(lambda (ioDrive)
    (if (vlax-property-available-p ioDrive 'SerialNumber)
    (setq ret (append ret (list (vlax-get-property ioDrive 'SerialNumber))))
    )
    )
    )
    )

    Can you post the code that you use to get your LODRIVES collection?

    Peter
     
    petersciganek, Jul 6, 2004
    #6
  7. jorgematheus

    jorgematheus Guest

    Hi

    As Juerg Menzi post earlier, SerialNumber seem no to be a property of ISWbemObjectSet, dídn't know why.

    I;m posting the code

    Thank
     
    jorgematheus, Jul 6, 2004
    #7
  8. jorgematheus

    jorgematheus Guest

    Hi

    I'm Still wondered. Why can't i call the item method.
    Why i can't do this
    (vlax-invoke-method lodrives "item 1)
    ; error: too few actual parameters

    Thank
     
    jorgematheus, Jul 7, 2004
    #8
  9. jorgematheus

    jorgematheus Guest

    Hi

    For who cares, here is the solution
    ; -- PHYHAR.lsp
    ; Return Manufacture Serial Number
    ; Copyright:
    ; ©2004 Jorge E. Matheus L. , Caracas Venzuela
    ; Licence: Freeware ( Just Mention were did you get from)
    ;
    ;
    (defun c:phyhar( / ret)
    (vl-load-com)
    (setq serx '())
    (if (SETQ OBJW (VLAX-CREATE-OBJECT "wbemScripting.SwbemLocator"))
    (progn
    (SETQ lccon (VLAX-INVOKE OBJW 'ConnectServer "." "\\root\\cimv2" "" "" "" "" 128 nil) )
    (setq lox (vlax-invoke lccon 'ExecQuery "Select SerialNumber,Tag from Win32_PhysicalMedia"))
    (vlax-for item lox (setq serx (cons (list (vlax-get item 'Tag)(vlax-get item 'SerialNumber)) serx)))
    (vlax-release-object lox)
    (vlax-release-object lccon)
    (vlax-release-object objW)
    )
    )
    (princ (reverse serx))
    (princ)
    )
     
    jorgematheus, Jul 26, 2004
    #9
  10. Does anyone know how can this program be modified to get the serial number
    of the local hard drive?
     
    Alan Henderson @ A'cad Solutions, Feb 16, 2005
    #10
  11. jorgematheus

    Jürg Menzi Guest

    Hi Alan

    Visit my homepage -> Free Stuff and search for 'VxGetDriveInfos'.

    Cheers
     
    Jürg Menzi, Feb 17, 2005
    #11
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.