Visual LISP, AutoLISP and General Customization

Posts: 11
Registered: ‎05-11-2006
Message 1 of 3 (85 Views)

clean BOM list in text

85 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.

(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))
(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))
;; 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)))
result (subst (cons item (1+ (cdr (assoc item result))))
(assoc item result)
{code} Edited by: jaswild69 on Mar 26, 2009 6:11 AM
Active Contributor
Posts: 35
Registered: ‎03-17-2009
Message 2 of 3 (85 Views)

Re: clean BOM list in text

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

Re: clean BOM list in text

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community