Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

clean BOM list in text

2 REPLIES 2
Reply
Message 1 of 3
jaswild69
260 Views, 2 Replies

clean BOM list in text

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
2 REPLIES 2
Message 2 of 3
st0neface
in reply to: jaswild69

did you turn osnaps off?
Message 3 of 3
jaswild69
in reply to: jaswild69

thanks, i feel retarded now.... 😄

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost