Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Contributor
jaswild69
Posts: 11
Registered: ‎05-11-2006
Message 1 of 3 (90 Views)

clean BOM list in text

90 Views, 2 Replies
03-25-2009 11:05 PM
I have gotten this routine to collect the objects I want to have listed. However, when I get to where I want to have the BOM list created there is an issue. When I create the list, the text will simply all be on top of each other, or there may be one or two spots where the y point actually changes. I have also noticed this routine tends to be a little 'picky'. If I am zoomed into a small group of text and create the BOM, this routine works flawlessly. If I zoom out a bit and pick the exact same group of text, the BOM comes out wrong.

{code}
(defun c:hh ( / )
(princ "\nSelect Objects:")
(setq ss1 (ssget '((0 . "TEXT"))))
(setq sslen (sslength ss1))
(setq slst nil)
(setq sn 0)
(while (< sn sslen)
(setq sent (entget (ssname ss1 sn)))
(setq sid (cdr (assoc 1 sent)))
(setq slst (cons sid slst))
(setq sn (+ sn 1))
);while
(setq flst (countitem slst))

;; here is my issue area -------------------------------------------------------
(setq x (getpoint "\nPick point for BOM text list: "))
(setq bomptx (car x))
(setq bompty (cadr x))
;(setq ent nil)
(foreach ent flst
(setq qty (cdr ent))
(setq sid (car ent))
(setq bomline (strcat (itoa qty) " " sid))
(command ".text" (list bomptx bompty) "" "" bomline) (princ (list bomptx bompty))
(setq bompty (- bompty 12))
)
(princ)
)
;; end of issue code ---------------------------------------------


;;; Count item in a list
;;; Ex: (countitem '(1 2 "a" 1 3 "a"))
;;; Return: ((1 . 2) (2 . 1) ("a" . 2) (3 . 1))
(defun countitem (dolist / item result uniquelist)
(foreach item dolist
(if (not (member item uniquelist))
(setq uniquelist (append uniquelist (list item))
result (append result (list (cons item 1)))
)
(setq
result (subst (cons item (1+ (cdr (assoc item result))))
(assoc item result)
result
)
)
)
)
result
)
{code} Edited by: jaswild69 on Mar 26, 2009 6:11 AM
Active Contributor
st0neface
Posts: 35
Registered: ‎03-17-2009
Message 2 of 3 (90 Views)

Re: clean BOM list in text

03-26-2009 12:52 AM in reply to: jaswild69
did you turn osnaps off?
Contributor
jaswild69
Posts: 11
Registered: ‎05-11-2006
Message 3 of 3 (90 Views)

Re: clean BOM list in text

03-26-2009 08:55 PM in reply to: jaswild69
thanks, i feel retarded now.... :smileyvery-happy:
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.