Results 1 to 8 of 8

Thread: Unknown string

  1. #1
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    N32° 32' 19.08", W-84° 52' 59.03"
    Posts
    1,280

    Default Unknown string

    What does this mean:

    Code:
      (setq SelSet (ssget "x" '((-4 . "<and" )(0 . "INSERT" )(2 . "MYBLOCK" )(-4 . "and>" ))) )
    I'm trying to modify this to include more than one block (instead of "MYBLOCK"), but I'm not sure what the "-4 . ", "2 . ", and "0 . " represent. If I were to add more block names to this selection set, how/why/what would I change these beginning numbers to?

    Thanks in advance,

    -pUnkn
    Phillip Bradshaw
    Lead Pixel Pusher, Lucid Design Studio
    CAD Administrator, Heatcraft RPD

    A doctor can bury his mistakes but an architect can only advise his clients to plant vines. - Frank Lloyd Wright

  2. #2
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    N32° 32' 19.08", W-84° 52' 59.03"
    Posts
    1,280

    Default Re: Unknown string

    Okay, I see that these numbers are "Associative Codes" (thanks AfraLisp), so I can work from there, but is there a list of all these codes and what they do?
    Phillip Bradshaw
    Lead Pixel Pusher, Lucid Design Studio
    CAD Administrator, Heatcraft RPD

    A doctor can bury his mistakes but an architect can only advise his clients to plant vines. - Frank Lloyd Wright

  3. #3
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473

    Default Re: Unknown string

    Code:
     (setq SelSet (ssget "x" '((-4 . "<and" )
    	                     (0 . "INSERT" )
    	                     (-4 . "<or")
    	                          (2 . "MYBLOCK");change to suit
                                                (2 . "MYOTHERBLOCK");change to suit
    	                     (-4 . "or>")
    	                     (-4 . "and>")
                                        );end filter
                        );ssget
     );setq
    Maybe this will help.

    The numbers are dxf codes. 0 is for the entity type, 2, in this case is the block name, and -4 lets the interpreter know that you are useing a logical operator string. There is a list of dxf codes in the help file.
    Tim Creary
    S&D
    DILLIGAF

  4. #4
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2002-12
    Location
    Brandon, Florida
    Posts
    687

    Default Re: Unknown string

    You must remember that AND is implied so this is all you need.
    Code:
     (setq SelSet (ssget "x" '((0 . "INSERT" )(2 . "MYBLOCK,MYBLOCK2" ))))

  5. #5
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473

    Default Re: Unknown string

    Quote Originally Posted by CAB2k View Post
    You must remember that AND is implied so this is all you need.
    Code:
     (setq SelSet (ssget "x" '((0 . "INSERT" )(2 . "MYBLOCK,MYBLOCK2" ))))
    Yeah, we were going to get to that but... ~shrug~

    Thanks, CAB
    Tim Creary
    S&D
    DILLIGAF

  6. #6
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    N32° 32' 19.08", W-84° 52' 59.03"
    Posts
    1,280

    Default Re: Unknown string

    Thanks you guys!

    Now that I've created my selection set, I need to extract the various attributes from them. I can't work on it right now, but I'll give it a shot tomorrow and update you all with my progress.
    Phillip Bradshaw
    Lead Pixel Pusher, Lucid Design Studio
    CAD Administrator, Heatcraft RPD

    A doctor can bury his mistakes but an architect can only advise his clients to plant vines. - Frank Lloyd Wright

  7. #7
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    N32° 32' 19.08", W-84° 52' 59.03"
    Posts
    1,280

    Default Re: Unknown string

    From what I've gathered from the help files in Vlisp, the way to extract attributes from a block is via:
    Code:
    RetVal = object.GetAttributes()
    How do I add this to my code (below), and how do I define the selection set I've created and which attributes to extract?

    If all the blocks listed aren't present, will that cause a problem? For that, should I add an "or" operator?

    Btw, do I need this?:
    Code:
    (vl-load-com)
    Routine so far:
    Code:
    (defun c:aavtest (/ SelSet )
    
     (vl-load-com)
    
     (setq SelSet (ssget "x" '((0 . "INSERT" )
                   (2 . "BARREL_ANCHOR,SPRING_LOAD,LIVE_END,DEAD_END,EYEBOLT_ASSEMBLY,INT_ANGLE,TERM_ANGLE,TERM_TUBE,INT_POST" ))))
    
    
    
    (princ)
    
    )
    Thanks for any advice!
    Last edited by stusic; 2008-01-24 at 02:47 PM.
    Phillip Bradshaw
    Lead Pixel Pusher, Lucid Design Studio
    CAD Administrator, Heatcraft RPD

    A doctor can bury his mistakes but an architect can only advise his clients to plant vines. - Frank Lloyd Wright

  8. #8
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2007-07
    Location
    Jo'burg SA
    Posts
    4,344

    Default Re: Unknown string

    Quote Originally Posted by stusic View Post
    From what I've gathered from the help files in Vlisp, the way to extract attributes from a block is via:
    Code:
    RetVal = object.GetAttributes()
    Uhmmm ... no, that's how you do it in VBA.

    Quote Originally Posted by stusic View Post
    How do I add this to my code (below), and how do I define the selection set I've created and which attributes to extract?
    If you really want to use the ActiveX methods, then either do your method in VBA or use the VLisp ActiveX extension functions:
    Code:
    (setq n 0)
    (vl-load-com)
    (while (< n (sslength SelSet))
      (setq bname (ssname SelSet n))
      (setq bobj (vlax-ename->vla-object bname))
      (setq AttrCollection (vlax-invoke-method bobj 'GetAttributes))
      ;; Do whatever you do with the attributes, just remember to use the vlax methods
      (setq n (1+ n))
    ) ;_ end of while
    Of course you'll have to look at the ActiveX methods as well as all those VLAX thingies for the Lisp interface thereto.

    I'd rather suggest not using ActiveX mixed into Lisp if not needed. It's usually faster using the normal Lisp routines instead. The only time you should use the VLAX methods is if the normal Lisp stuff doesn't provide the needed functions.
    Code:
    (setq n 0)
    (while (< n (sslength SelSet))
      (setq bname (ssname SelSet n))
      (setq battr (entnext bname))        ;Get the next entity after the nth block
      (while (and
           battr            ;Check if the entity is found
           (setq battrdata (entget battr)) ;Get its data
           (= "ATTRIB" (cdr (assoc 0 battrdata)))
                        ;Check if it's an attribute
         ) ;_ end of and
        ;; Do whatever you do with the current attribute, just remember to use the normal lisp methods
        ;; E.g. (cdr (assoc 1 battrdata)) gives the text value of the attribute
        ;;      (cdr (assoc 2 battrdata)) gives the attribute's tag name
        ;; Check the DXF code in the help file for other properties you can obtain this way
        (setq battr (entnext battr))    ;Get next entity after the attribute you've just found
      ) ;_ end of while
    
      (setq n (1+ n))
    ) ;_ end of while
    Quote Originally Posted by stusic View Post
    If all the blocks listed aren't present, will that cause a problem? For that, should I add an "or" operator?
    No, the commas in the name are analogous to OR. You could also use wildcard characters like * (asterisk) to match say BLK* to all of BLK1, BLK234, BLKwhatever, etc.

    Quote Originally Posted by stusic View Post
    Btw, do I need this?: (vl-load-com)
    Only if you're going to use ActiveX methods inside a Lisp function. This just ensures that the VLisp AxtiveX extension interface is loaded. Otherwise you might find "unknown function" errors.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

Similar Threads

  1. Unknown Errors
    By tonyv in forum CAD Management - General
    Replies: 3
    Last Post: 2011-06-13, 09:57 PM
  2. Unknown command
    By ccowgill in forum AutoLISP
    Replies: 4
    Last Post: 2010-07-29, 05:05 PM
  3. CUI - Unknown command
    By fishervb in forum AutoCAD CUI Menus
    Replies: 8
    Last Post: 2007-10-25, 10:53 PM
  4. unknown error on STC
    By williamsmitchell in forum Revit Architecture - General
    Replies: 2
    Last Post: 2007-10-13, 03:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •