Results 1 to 7 of 7

Thread: Need Help Understanding Attached Lisp

  1. #1
    Member
    Join Date
    2005-11
    Location
    Daly City, Ca.
    Posts
    40

    Default Need Help Understanding Attached Lisp

    I need help understanding this lisp. It was created for me by an augi member but i can't recall who and when that was. Now our block has changed and the lisp is not working properly.

    The lisp is suppose to bump all the revision line attributes up 1 to make room for a new line. We now have 10 lines of revision, each line has 10 attributes. The first line stays as is, the second line gets bumped out and replaced by the 3rd line and so on and so forth leaving the last line empty for the new revision information.

    If someone can decipher and translate that would be helpful. I'd like to understand and hopefully be able to update it as necessary.

    Thanks for the help. I've attached a couple of files, the old border and the new border. We removed 22 lines of attributes which i think messed w/ the calculations.

    Here's the lisp
    (defun C:BMP (/ intBase intItem intRecord lstOfSublists ssSelections)
    (if (setq ssSelections (ssget "x" (list (cons 0 "insert")(cons 2 "100-G13-BDR-E-FP")(cons 410 (getvar "ctab")))))
    (progn
    (vl-load-com)
    (vlax-for objItem (vla-get-activeselectionset
    (vla-get-activedocument
    (vlax-get-acad-object)))
    (setq lstOfSublists (getattributesublists objItem)
    intBase 17
    intRecord 7
    )
    (repeat 10
    (setq intItem 11)
    (repeat 12
    (if (<= intRecord 14)
    (vla-put-textstring (nth 2 (nth (- (* (1- intRecord) 12) intBase intItem) lstOfSublists))
    (vla-get-textstring (nth 2 (nth (- (* intRecord 12) intBase intItem)
    lstOfSublists
    )
    )
    )
    )
    (vla-put-textstring (nth 2 (nth (- (* (1- intRecord) 12) intBase intItem) lstOfSublists))
    ""
    )
    )
    (setq intItem (1+ intItem))
    )
    (setq intRecord (1+ intRecord))
    )
    )
    )
    )
    )

    (defun GetAllAttributes (objSelection /)
    (if (= (type objSelection) 'ENAME)
    (setq objSelection (vlax-ename->vla-object objSelection))
    )
    (if (vlax-property-available-p objSelection "hasattributes")
    (if (= (vla-get-hasattributes objSelection) :vlax-true)
    (vlax-safearray->list
    (variant-value
    (vla-getattributes objSelection)
    )
    )
    )
    )
    )


    (defun GetAttributeSubLists (objSelection / lstAttributes)
    (if (setq lstAttributes (getAllAttributes objSelection))
    (progn
    ; (princ lstAttributes)
    (mapcar '(lambda (objAttribute) (list (strcase (vla-get-tagstring objAttribute))
    (vla-get-textstring objAttribute)
    objAttribute
    )
    )
    lstAttributes
    )
    )
    )
    )
    (princ)
    Attached Files Attached Files

  2. #2
    I could stop if I wanted to pbejse's Avatar
    Join Date
    2010-10
    Posts
    395

    Default Re: Need Help Understanding Attached Lisp

    I would've help you only if i can open the file....The problem is fairly easy

    W'ere still stuck with Autocad 2009 though
    Last edited by pbejse; 2011-01-11 at 10:44 AM.

  3. #3
    Member
    Join Date
    2005-11
    Location
    Daly City, Ca.
    Posts
    40

    Default Re: Need Help Understanding Attached Lisp

    I've attached a 2007 version. Thanks for the help.
    Attached Files Attached Files

  4. #4
    I could stop if I wanted to pbejse's Avatar
    Join Date
    2010-10
    Posts
    395

    Default Re: Need Help Understanding Attached Lisp

    Quote Originally Posted by sumulong788473 View Post
    I've attached a 2007 version. Thanks for the help.
    Code:
    (defun C:BMP (/ intBase intItem intRecord lstOfSublists ssSelections)
    (if (setq ssSelections (ssget "x" (list (cons 0 "insert")(cons 2 "100-G13-BDR-E-FP")(cons 410 (getvar "ctab")))))
    (progn
    (vl-load-com)
    (vlax-for objItem (vla-get-activeselectionset 
    (vla-get-activedocument 
    (vlax-get-acad-object)))
    (setq lstOfSublists (getattributesublists objItem)
      temp lstOfSublists
    intBase 17
    intRecord 7
    )
    (repeat 10
    (setq intItem 15)
    (repeat 10
    (if (<= intRecord 15)
    (vla-put-textstring (nth 2 (nth (- (* (1- intRecord) 10) intBase intItem) lstOfSublists))
    (vla-get-textstring (nth 2 (nth (- (* intRecord 10) intBase intItem)
    lstOfSublists
    )
    )
    )
    )
    (vla-put-textstring (nth 2 (nth (- (* (1- intRecord) 10) intBase intItem) lstOfSublists))
    ""
    )
    )
    (setq intItem (1+ intItem))
    )
    (setq intRecord (1+ intRecord))
    )
    (setq cnt 18 rev_nm (strcat "REFER TO PREVIOUS FILES FOR REVISIONS 0 THRU " (itoa (-
    	    	(atoi (vla-get-textstring (nth 2 (nth 29 lstOfSublists)))) 1)))
    	    	as_is
    	  	(mapcar '(lambda (p)
    			   	(vla-put-textstring (nth 2 (nth (setq cnt (1+ cnt)) lstOfSublists)) (eval p)))
    				  	'("-" rev_nm "" "" "-" "" "" "-" "-" "-")) cnt_ 0)  
    )
    )
    )
    )
    
    (defun GetAllAttributes (objSelection /)
    (if (= (type objSelection) 'ENAME)
    (setq objSelection (vlax-ename->vla-object objSelection))
    )
    (if (vlax-property-available-p objSelection "hasattributes") 
    (if (= (vla-get-hasattributes objSelection) :vlax-true) 
    (vlax-safearray->list 
    (variant-value 
    (vla-getattributes objSelection)
    )
    ) 
    )
    )
    )
    
    
    (defun GetAttributeSubLists (objSelection / lstAttributes)
    (if (setq lstAttributes (getAllAttributes objSelection))
    (progn
    ; (princ lstAttributes)
    (mapcar '(lambda (objAttribute) (list (strcase (vla-get-tagstring objAttribute))
    (vla-get-textstring objAttribute)
    objAttribute
    )
    )
    lstAttributes
    )
    )
    )
    )
    (princ)
    Try this with your new border and tell me what you think

    EDIT: i overlooked the 1st Rev (i automate the number to match the 2nd line rev no.)

    Code:
    
    (setq cnt 18 rev_nm (strcat "REFER TO PREVIOUS FILES FOR REVISIONS 0 THRU " (itoa (-
    	    	(atoi (vla-get-textstring (nth 2 (nth 29 lstOfSublists)))) 1)))
    	    	as_is
    	  	(mapcar '(lambda (p)
    			   	(vla-put-textstring (nth 2 (nth (setq cnt (1+ cnt)) lstOfSublists)) (eval p)))
    				  	'("-" rev_nm "" "" "-" "" "" "-" "-" "-")) cnt_ 0)
    
    Attached Files Attached Files
    Last edited by pbejse; 2011-01-13 at 11:36 AM. Reason: highlight

  5. #5
    Past Vice President peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu Hawaii
    Posts
    574

    Default Re: Need Help Understanding Attached Lisp

    Since these are functions that I created, I can explain what they do.

    The function accepts one argument that is either an entityname or a vla-object of a block with attributes and returns a list of attribute objects. There are some error checking conditionals to make sure the object has the hasattributes property and is true.

    Code:
    (defun GetAllAttributes (objSelection /)
     (if (= (type objSelection) 'ENAME)
      (setq objSelection (vlax-ename->vla-object objSelection))
      )
     (if (vlax-property-available-p objSelection "hasattributes") 
      (if (= (vla-get-hasattributes objSelection) :vlax-true) 
       (vlax-safearray->list 
        (variant-value 
         (vla-getattributes objSelection)
        )
       ) 
      )
     )
    )
    Without the error checking and assuming you are passing a block vla-object you can rewrite it thus and it will return a list of attribute objects.

    Code:
    (defun GetAllAttributes (objSelection)
     (vlax-invoke objSelection "getattributes")
    )
    Peter
    AUGI Volunteer

  6. #6
    Past Vice President peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu Hawaii
    Posts
    574

    Default Re: Need Help Understanding Attached Lisp

    This function accepts an entity name or vla object of a block and returns a list of sublists. Each sublist contains the uppercase tagstring, textstring and the attribute object of each attribute.

    Peter

    Code:
    (defun GetAttributeSubLists (objSelection / lstAttributes)
     (if (setq lstAttributes (getAllAttributes objSelection))
      (progn
      ; (princ lstAttributes)
       (mapcar '(lambda (objAttribute)
                 (list (strcase (vla-get-tagstring objAttribute))
                       (vla-get-textstring objAttribute)
                       objAttribute
                 )
                )
                lstAttributes
       )
      )
     )
    )
    AUGI Volunteer

  7. #7
    I could stop if I wanted to pbejse's Avatar
    Join Date
    2010-10
    Posts
    395

    Smile Re: Need Help Understanding Attached Lisp

    Quote Originally Posted by Peter View Post
    Since these are functions that I created, I can explain what they do.

    Peter
    Hope I did justice with your orignal bmp.slp

    Thank you for explaining the codes to the OP

Similar Threads

  1. Understanding Lookup
    By bcole.200021 in forum Dynamic Blocks - Technical
    Replies: 2
    Last Post: 2009-04-06, 09:05 PM
  2. Replies: 2
    Last Post: 2007-05-11, 11:25 AM
  3. Replies: 0
    Last Post: 2007-04-30, 05:05 PM
  4. Is it possible to draw attached image via a LISP routine?
    By BRENDA_GZZ_GOMEZ in forum AutoLISP
    Replies: 6
    Last Post: 2007-04-16, 09:00 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
  •