mbaumhardt645 Posted August 2, 2013 Share Posted August 2, 2013 I’m new to using AutoLISP and have been trying to educate myself on how it works. By looking at examples, I’m able to determine what is happening. However, I’m having a difficult time trying to update an existing LISP routine that my company uses. The creator has recently left. I don’t know what to change, where exactly to change it, or how to change/add anything. Here is my situation. Our current LISP routine asks the user to select the standard blocks that they want to include. Every block that is selected will always has the same 4 attribute tags embedded within (values change). Three of these attributes (“FAMILY”, “DESCRIPTION”, & “PN”) are set to constant and the 4th (“SEC_NO”) can be user defined. The LIPS routine takes these values and creates a table w/ the headings “SECTION NO”, “FAMILY”, “DESCRIPTION”, & “PN” in that order. This works perfectly. However, I am changing the way the blocks are created so they are more easily created and managed (turned them into dynamic blocks). By doing this, I have created extra attributes in the new blocks. These extra attributes screw up our current LISP routine. I would like to modify this routine so that it creates a list of the attribute values pulled from the same 4 attributes listed above (“SEC_NO”, “FAMILY”, “DESCRIPTION”, & “PN”) and ignore the rest. The tag names of the attributes will always remain the same. Below is the part of the routine that creates the list used for the table. Any help would be greatly appreciated. If there is a simpler way to do it, I’m all ears. -Mark (defun get-all-atts (obj / atts att_list const_atts const_list ent) (and (if (and obj (vlax-property-available-p obj 'Hasattributes) (eq :vlax-true (vla-get-hasattributes obj)) ) (progn (if (not (vl-catch-all-error-p (vl-catch-all-apply (function (lambda () (setq atts (vlax-invoke obj 'Getattributes)) ) ) ) ) ) (setq (progn (foreach att atts (setq att_list (cons (cons (vla-get-tagstring att) (vla-get-textstring att) ) att_list ) ) ) ) ) (if (not (vl-catch-all-error-p (vl-catch-all-apply (function (lambda () (setq const_atts (vlax-invoke obj 'Getconstantattributes ) ) ) ) ) ) ) (progn (foreach att const_atts (setq const_list (cons (cons (vla-get-tagstring att) (vla-get-textstring att) ) const_list ) ) ) (setq att_list (append const_list att_list)) ) ) ) ) ) (reverse att_list) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 3, 2013 Share Posted August 3, 2013 Hi Mark, Substitute the following in place of your code: (defun get-all-atts ( obj / lst tag ) (if (and obj (vlax-property-available-p obj 'hasattributes) (= :vlax-true (vla-get-hasattributes obj))) (foreach att (append (vlax-invoke obj 'getattributes) (vlax-invoke obj 'getconstantattributes)) (if (member (strcase (setq tag (vla-get-tagstring att))) '("FAMILY" "DESCRIPTION" "PN" "SEC_NO")) (setq lst (cons (cons tag (vla-get-textstring att)) lst)) ) ) ) (reverse lst) ) You may also find my library of Attribute Functions useful. Welcome to CADTutor Quote Link to comment Share on other sites More sharing options...
Guest Posted August 3, 2013 Share Posted August 3, 2013 Why you don't use EATTEXT Quote Link to comment Share on other sites More sharing options...
mbaumhardt645 Posted August 5, 2013 Author Share Posted August 5, 2013 prodromosm, I thought about EATTEXT at one point, but didn't want to use attribute extraction in order to keep our process as simple as possible for our designers to use. I'm trying to minimize the number of clicks and make it fool proof. Thanks for the reply though. Lee Mac, Your code works perfectly. I had a feeling it could've been written a lot cleaner and simpler. Also, I have been to your "Attribute Functions" page last week looking for help. However, since I'm new to LISP, I had a hard time determining what to use and what I needed to add/change to make it work for my application. I'm more familiar w/ VBA in Excel. Thanks for the help. I really appreciate it! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 5, 2013 Share Posted August 5, 2013 You're most welcome - Just ask if you are unsure how to call my Attribute Functions from your program. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.