Jump to content
CADkitt

making a bom list from blocks with attributes

Recommended Posts

CADkitt

Edit:

Watched this

at first I didn't want to go to excel but after watching that....it changed my mind a bit.

 

 

 

I am working on a project for automation of bom list.

I searched the web a bit and found this:

c# program for making a table of attributes:

http://through-the-interface.typepad.com/through_the_interface/2007/06/creating_a_tabl.html

Don't know how to run it :(

A lisp for creating a table of attributes.

http://forums.cadalyst.com/showthread.php?t=6430

Works pretty good but missing some pretty important stuff. See this image:

bom.jpg

 

I used eattext

This very powerful autocad function is like other powerful autocad function and only works for 90% it is missing:

No balloon numbers added, can be done pretty easy be hand.

Can't be used in paperspace when blocks are in modelspace. Which is always...

Work around is using chspace, but then scale is screwed. aaaaargh :ouch:

 

So in conclusion the best way for me will be updating the lisp.

Or some one already did this and want to share :) or help?

I think merging the same block names will be hardest so if any one has any idea on how to do this?

Attributes to Table lisp from the second link:

(Defun c:attable (/ at>att at>item at>set atable cnt cw ena nc nr pt rh)
   (vl-load-com)
   ;; GET_ATTS BY BILL KRAMER
   (defun get_ATTS (EN / EL ATTS)
(setq EL (entget EN))
(setq ENA (cdr (assoc 2 EL))) ; wiz
(if (and (= (cdr (assoc 0 EL)) "INSERT")
	 (= (cdr (assoc 66 EL)) 1)
    ) ;_ end and
    (progn
	(setq EN (entnext EN)
	      EL (entget EN)
	) ;_ end setq
	(while (= (cdr (assoc 0 EL)) "ATTRIB")
	    (setq ATTS (cons (list
				 (vla-get-ObjectID
				     (vlax-ename->vla-object EN)
				 ) ; wiz
				 (cdr
				     (assoc 2 EL)
				 ) ;_ end_cdr
				 (cdr (assoc 1 EL))
			     ) ;_ end_list
			     ATTS
		       ) ;_ end_cons
		  EN   (entnext EN)
		  EL   (entget EN)
	    ) ;_ end setq
	) ;_ end while
	(list ena (reverse ATTS)) ; wiz
    ) ;_ end progn
) ;_ end if
   ) ;_ end_defun
   (if	(setq at>set (ssget '((0 . "INSERT"))))
(progn
    (setq at>att
	     (mapcar 'get_atts
		     (vl-remove-if
			 'listp
			 (mapcar 'cadr (ssnamex at>set))
		     ) ;_ end_vl-remove-if
	     ) ;_ end_mapcar
    ) ;_ end_setq
    (setq PT (getpoint "\nTable insertion point: ")
	  RH (* 2.0 (getvar "TEXTSIZE"))
	  CW (* 20.0 (getvar "TEXTSIZE"))
	  NR (+ 2 (length at>att))
	  NC (1+ (length (cadar at>att)))
    ) ;_ end_setq
    (setq
	aTable (vla-addtable
		   (vla-get-modelspace
		       (vla-get-activedocument
			   (vlax-get-acad-object)
		       ) ;_ end_vla-get-activedocument
		   ) ;_ end_vla-get-modelspace
		   (vlax-3d-point PT)
		   NR
		   NC
		   RH
		   CW
	       ) ;_ end_vla-addtable
    ) ;_ end_setq
    (vla-setcellvalue aTable 0 0 "B.O.M.")
    (vla-setcellvalue aTable 1 0 "Block Name")
    (vla-setcellvalue aTable 1 1 "Attributes")
    (vla-MergeCells aTable 1 1 1 (length (cadar at>att)))
    (setq CNT 2) ;_ end_setq
    (foreach Item at>att
	(vla-setcellvalue aTable CNT 0 (car Item))
	(setq at>item 1)
	(while (<= at>item (length (cadar at>att)))
	    (vl-catch-all-apply
		'(lambda ()
		     (vla-settext
			 aTable
			 CNT
			 at>item
			 (strcat
			     "%<\\AcObjProp Object(%<\\_ObjId "
			     (itoa (car (nth (1- at>item) (cadr Item))))
			     ">%).TextString>%"
			 ) ;_ end_strcat
		     ) ;_ end_vla-setcellvalue
		 ) ;_ end_lambda
	    ) ;_ end_vl-catch-all-apply
	    (setq at>item (1+ at>item))
	) ;_ end_while
	(setq CNT (1+ CNT))
	;;ready next row
    ) ;_ end_foreach
) ;_ end_progn
   ) ;_ end_if
   (princ)
) ;_ end_Defun

Edit found lee mac code for counting blocks and it also merge same blocks:

http://www.cadtutor.net/forum/showthread.php?51370-List-of-blocks&highlight=list+blocks

Now to frankenbuild the 2 together :)

Edited by CADkitt

Share this post


Link to post
Share on other sites
littlepeterpan821

Hjx, I have the same request! anybody help us, please!

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...