+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Full Member
    Using
    Revit 2015
    Join Date
    Dec 2006
    Location
    Las Vegas, NV
    Posts
    48

    Default bill of materials lisp Help??

    Registered forum members do not see this ad.

    Hello everyone. I have been trying to figure how to Automate Autocad. I seen it done before for cut listing steel. Am trying to add a material ID to some stone which there can be roughly 5,000 different pieces. I need autcad to identify the material ID and give me a total of that size. For example: Material ID "1-1T" = W5'-0"xH7'-0". Then output it to either excel or notepad format. I tried making different blocks for each one then use either FIND or QSELECT, but it's as accurate as I need it. I need to basically create a bill of materials lisp of some short. I hope that made sense. Thanks

  2. #2
    Luminous Being tzframpton's Avatar
    Computer Details
    tzframpton's Computer Details
    Computer:
    Custom built rig
    Discipline
    Multi-disciplinary
    tzframpton's Discipline Details
    Occupation
    BIM Specialist
    Discipline
    Multi-disciplinary
    Details
    Facilities engineering, involving mechanical piping, mechanical HVAC, electrical and structural engineering.
    Using
    Revit 2015
    Join Date
    Mar 2006
    Location
    Dallas, TX - USA
    Posts
    7,799

    Default

    for blocks, try using the BCOUNT command. when it says "Select Objects..." just type all and hit Enter, hit F2 to get a better view. does an automatic count of all blocks. or you can just type the block name for single counts. or pick them, doesn't matter. however you wanna do it.
    Tannar Z. Frampton | Hill & Wilkinson

  3. #3
    Full Member
    Using
    Revit 2015
    Join Date
    Dec 2006
    Location
    Las Vegas, NV
    Posts
    48

    Default

    Thanks.. I also found a pretty cool lisp.

    http://www.jefferypsanders.com/autolisp_blocks.html

  4. #4
    Full Member
    Using
    AutoCAD 2014
    Join Date
    Dec 2006
    Location
    Barcelona, Catalunya
    Posts
    92

    Default Great

    This lisp is ALMOST exactly what I´m looking for...does anyone know how I can make it send the blocks to certain Excel cells instead of of a CSV file? What I would like to do is have it look for all the blocks in a drawing that represent different components (like a threaded rod for example) and have that block go to a certain cell so that I can use excel to automatically calculate the amount of washers and nuts that I need for it.

  5. #5
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Thanks God, I'm far enough from Hitleropa
    Posts
    1,697

    Default

    Quote Originally Posted by Shiloh View Post
    This lisp is ALMOST exactly what I´m looking for...does anyone know how I can make it send the blocks to certain Excel cells instead of of a CSV file? What I would like to do is have it look for all the blocks in a drawing that represent different components (like a threaded rod for example) and have that block go to a certain cell so that I can use excel to automatically calculate the amount of washers and nuts that I need for it.
    Shilon
    Attach your sample drawing here
    I 've wrote similar lisp some time ago but
    I need a certain drawing to test a result

    ~'J'~

  6. #6
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Thanks God, I'm far enough from Hitleropa
    Posts
    1,697

    Default

    Here is this lisp
    Code:
    ;; Helper function 'count-blocks'
    
    ;; written by Fatty(c) 2005 * all rights removed
    (defun count-blocks (/ acsp adoc bname bname_list tmp_list ss tmp)
      (vl-load-com)
      (setq	adoc (vla-get-activedocument
    	       (vlax-get-acad-object)
    	     )
    	acsp (vla-get-block
    	       (vla-get-activelayout adoc)
    	     )
      )
      (command "_.zoom" "_e")
      (setq	ss (ssget "_X"
    		  (list (cons 0 "INSERT") ;|(cons 2 "block1,block2,block3")|;);your block names here
    	   )
      )
      (vlax-for a (vla-get-activeselectionset adoc)
        (if	(wcmatch (vla-get-objectname a) "AcDbBlockReference*")
          (progn
    	(setq bname (vla-get-name a))
    	(setq bname_list (cons bname bname_list))
          )
        )
      )
      (while (car bname_list)
        (setq tmp (list (vl-remove-if-not
    		      (function	(lambda	(a)
    				  (eq a (car bname_list))
    				)
    		      )
    		      bname_list
    		    )
    	      )
        )
        (setq tmp_list (cons (car tmp) tmp_list))
        (setq bname_list
    	   (vl-remove-if
    	     (function (lambda (a)
    			 (eq a (car bname_list))
    		       )
    	     )
    	     bname_list
    	   )
        )
        (setq tmp nil)
      )
    
      (setq	tmp_list	(mapcar	(function (lambda (x)
    				    (list (car x) (length x))
    				  )
    			)
    			(reverse tmp_list)
    		)
      )
    
      tmp_list
    )
    ;CaLL:(count-blocks);ok
    
    ;; 		Main program			;
    
    ;;; Based on program 'Excel' written by
    ;;; ALEJANDRO LEGUIZAMON - arquingeneu@gmail.com
    ;;; edited by Fatty
    
    (defun c:cbl (/ LAYER# LIST# N ROW TOTALVALUE VALUE)
    
      (vl-load-com)
      (setq	*AplExcel*	   (vlax-get-or-create-object "Excel.application")
    	*Books-Colection*  (vlax-get-property *AplExcel* "Workbooks")
    	*New-Book*	   (vlax-invoke-method *Books-Colection* "Add")
    	*Sheet-Collection* (vlax-get-property *New-Book* "Sheets")
    	*Sheet#1*	   (vlax-get-property *Sheet-Collection* "Item" 1)
    	*excell-cells*	   (vlax-get-property *Sheet#1* "Cells")
      )
      (vla-put-visible *AplExcel* :vlax-true)
      (setq row 4)
      (setq n 0)
      (setq totalvalue 0)
      (princ "\nCOUNTING BLOCKS IN DRAWING")
      (setq list# (count-blocks))
    
      (setq totalvalue (apply '+ (mapcar 'cadr list#)))
      (repeat (length list#)
        (setq value (cadar list#))
        (vlax-put-property
          *excell-cells*
          "Item"
          row
          2
          (vl-princ-to-string value)
        )
    
        (setq layer# (caar list#))
        (vlax-put-property
          *excell-cells*
          "Item"
          row
          1
          (vl-princ-to-string layer#)
        )
        (setq list# (cdr list#))
        (setq n (+ n 1))
        (setq row (+ row 1))
      )
    
      (setq row (+ row 1))
      (vlax-put-property
        *excell-cells*
        "Item"
        row
        1
        (vl-princ-to-string "TOTAL")
      )
    
      (vlax-put-property
        *excell-cells*
        "Item"
        row
        2
        (vl-princ-to-string totalvalue)
      )
    
      (vlax-put-property
        *excell-cells*
        "Item"
        1
        1
        (vl-princ-to-string
          " Based on routine by  ALEJANDRO LEGUIZAMON -  http://arquingen.tripod.com.co"
        )
      )
    
      (vlax-put-property
        *excell-cells*
        "Item"
        2
        1
        (vl-princ-to-string
          (strcat "COUNTING BLOCKS IN DRAWING: " (getvar "dwgprefix"))
        )
      )
      (vlax-put-property
        *excell-cells*
        "Item"
        3
        1
        (vl-princ-to-string "Block name")
      )
      (vlax-put-property
        *excell-cells*
        "Item"
        3
        2
        (vl-princ-to-string "Subtotal")
      )
    
      (vlax-release-object *excell-cells*)
      (vlax-release-object *Sheet#1*)
      (vlax-release-object *Sheet-Collection*)
      (vlax-release-object *New-Book*)
      (vlax-release-object *Books-Colection*)
      (vlax-release-object *AplExcel*)
      (alert "Save Excel file manually")
    )
    
    (prompt "\nType CBL to execute ...")
    (princ)
    ~'J'~

  7. #7
    Senior Member
    Using
    AutoCAD 2006
    Join Date
    Jul 2007
    Posts
    117

    Default Export to Access

    Hi,

    Just got playing with this lisp from http://www.jefferypsanders.com/autolisp_blocks.html
    very nice.

    Is there a way to export it to an access database easily?

    I saw the code for Excel but I use Access 2000

    Bill

  8. #8
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Thanks God, I'm far enough from Hitleropa
    Posts
    1,697

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Impala62 View Post
    Hi,

    Just got playing with this lisp from http://www.jefferypsanders.com/autolisp_blocks.html
    very nice.

    Is there a way to export it to an access database easily?

    I saw the code for Excel but I use Access 2000

    Bill
    I have some experience on this way but
    better yet take look at ADOLIsp Library:

    http://acad.fleming-group.com/

    this ought be a good starting point for you

    ~'J'~

Similar Threads

  1. materials
    By Rivendell in forum AutoCAD General
    Replies: 7
    Last Post: 9th Jul 2006, 10:21 am
  2. Bill of Materials ???? ASAP
    By Urbino in forum AutoCAD Beginners' Area
    Replies: 8
    Last Post: 21st Apr 2006, 04:20 pm
  3. Using materials
    By Dubplate in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 8th Feb 2006, 03:50 pm
  4. 3D MAX 6 materials
    By Jon in forum AutoCAD 3D Modelling & Rendering
    Replies: 2
    Last Post: 12th Jul 2004, 10:10 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts