Author Topic: BOM Utility to extract selective attributes from blocks with tabulation  (Read 17650 times)

0 Members and 1 Guest are viewing this topic.

fixo

  • Guest
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #15 on: October 11, 2008, 01:06:46 PM »
Okay, draw this table manually, please, say 3-4 rows
Not clearly enough for me how it must looks like
Then upload screenshot here :oops:

~'J'~

Arthur Gan

  • Guest
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #16 on: October 11, 2008, 02:52:03 PM »
thanks for continuing, here's my sketch of the user interface..
let me know if you need explanation.
thanks!

fixo

  • Guest
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #17 on: October 11, 2008, 04:00:17 PM »
Still swamped..
Check your post, please

~'J'~

Arthur Gan

  • Guest
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #18 on: October 13, 2008, 01:23:45 AM »
just checkout AutoCAD's EATTEXT, your are right, it is similar to what this BOM request.
i've not worked with AutoCAD since R14 and neither any of our customers have shown us this feature..
this request was conceived when we visited a prospect who was requesting to evaluate Bricscad and i take is as our responsibility to understand their drafting requirements to proposed them a suitable product or how best Bricscad can work for them..

GDF

  • Water Moccasin
  • Posts: 2081
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #19 on: October 13, 2008, 11:43:33 AM »
I'm late to the party...go to this site:
www.waun.org

Ask Peter Jamtgaard for the routine below:

Code: [Select]
    ;***************************************************************************************
    ;***************************************************************************************

    ; Table Magic Autodesk University 2006 Lecture
    ; Written By: Peter Jamtgaard P.E. copr 2007 all rights reserved
    ; The compilation of Visual LISP functions create AutoCAD tables
    ; Each function or subroutine has a header to explain its function
    ; along with a listing of variables descriptions.
    ; These routines are based on AutoCAD 2007 Visual LISP functions.

    ; This file includes: C:BillOfMaterials
    ; C:BOMDialog
    ;                       C:CSVFileToTable
    ;                       C:Schedule

    ;***************************************************************************************
    ;***************************************************************************************

    ; This functions uses a dialog box to allow the user to change the costs of blocks
    ; and to exclude blocks from the bill of materials


Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #21 on: October 13, 2008, 01:28:11 PM »
Here is my contribution ( I was bored ).  I'm sure you will have to change the row height and column width ( colored in red ), but it works.  Just place all code in one file, and place the .dcl file in a support path, and load the file and run it.  Enjoy.  Hope you learn from it also.   :-)

Edit: Updated code.  I was going to leave the old, but you can't strike through in code, so I just took it out.  I was getting some errors, so I fixed them.
Code: [Select]
(defun c:Test (/ ActDoc cSpace ss cnt Ent EntData tempList tempName BlkNameList DiaRtn TagNValueList BlkName RowCnt tempDiaRtn
    tempInsPt ValueList tempTbl ColCnt MaxRowCnt)
   
    (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (vla-EndUndoMark ActDoc)
    (vla-StartUndoMark ActDoc)
    (setq cSpace (vlax-get ActDoc (if (equal (getvar 'CVport) 1) 'PaperSpace 'ModelSpace)))
    (if
        (and
            (setq ss (ssget "x" '((0 . "INSERT") (66 . 1))))
            (setq cnt -1)
            (while (setq Ent (ssname ss (setq cnt (1+ cnt))))
                (setq EntData (entget Ent))
                (if (setq tempList (assoc (setq tempName (cdr (assoc 2 EntData))) BlkNameList))
                    (setq BlkNameList (subst (cons tempName (cons Ent (cdr tempList))) tempList BlkNameList))
                    (setq BlkNameList (cons (list tempName Ent) BlkNameList))
                )
            )
            (setq BlkNameList (vl-sort BlkNameList '(lambda (a b) (< (strcase (car a)) (strcase (car b))))))
            (setq DiaRtn (MultiSelect (mapcar 'car BlkNameList) "Select blocks to extract attributes." nil))
        )
        (foreach i DiaRtn
            (setq TagNValueList nil)
            (setq ValueList nil)
            (setq tempList (nth i BlkNameList))
            (setq BlkName (car tempList))
            (setq RowCnt (1+ (length tempList)))
            (setq MaxRowCnt RowCnt)
            (setq Ent (cadr tempList))
            (while
                (and
                    (setq Ent (entnext Ent))
                    (setq EntData (entget Ent))
                    (= (cdr (assoc 0 EntData)) "ATTRIB")
                )
                (setq TagNValueList (cons (list (cdr (assoc 2 EntData)) (cdr (assoc 1 EntData))) TagNValueList))
            )
            (if
                (and
                    (setq tempDiaRtn (MultiSelect (mapcar 'car TagNValueList) "Select attributes to extract." nil))
                    (setq tempInsPt (getpoint "\n Select upper left hand corner for table insert."))
                )
                (progn
                    (foreach j tempDiaRtn
                        (setq ValueList (cons (nth j TagNValueList) ValueList))
                    )
                    (foreach j (cddr tempList)
                        (setq Ent j)
                        (while
                            (and
                                (setq Ent (entnext Ent))
                                (setq EntData (entget Ent))
                                (= (cdr (assoc 0 EntData)) "ATTRIB")
                            )
                            (if (setq tempList (assoc (setq tempTag (cdr (assoc 2 EntData))) ValueList))
                                (setq ValueList (subst (cons tempTag (cons (cdr (assoc 1 EntData)) (cdr tempList))) tempList ValueList))
                            )
                        )
                    )
                    (setq tempTbl
                        (vlax-invoke
                            cSpace
                            'AddTable
                            tempInsPt
                            RowCnt
                            (setq ColCnt (length ValueList))
                            [color=red](/ 3 32.)
                            0.5[/color]
                        )
                    )
                    (vla-put-RegenerateTableSuppressed tempTbl :vlax-true)
                    (vla-put-TitleSuppressed tempTbl :vlax-false)
                    (vla-SetText tempTbl 0 0 BlkName)
                    (vl-catch-all-apply 'vla-MergeCells (list tempTbl 0 0 0 (1- ColCnt)))
                    (vla-put-HeaderSuppressed tempTbl :vlax-false)
                    (setq ColCnt 0)
                    (foreach j ValueList
                        (setq RowCnt 1)
                        (foreach k j
                            (if (< RowCnt MaxRowCnt)
                                (vla-SetText tempTbl RowCnt ColCnt k)
                                (prompt (strcat "\n Extra value in block: " BlkName ", Tag: " (car j) ", Value: " k))
                            )
                            (setq RowCnt (1+ RowCnt))
                        )
                        (setq ColCnt (1+ ColCnt))
                    )
                    (vla-put-RegenerateTableSuppressed tempTbl :vlax-false)
                )
            )
        )
    )
    (vla-Regen ActDoc acActiveViewport)
    (vla-EndUndoMark ActDoc)
    (princ)
)
Sub needed
Code: [Select]
(defun MultiSelect (Listof Message Toggle / DiaLoad tmpStr tmpTog tmpList)

(setq DiaLoad (load_dialog "MyDialogs.dcl"))
(if (new_dialog "MultiSelect" DiaLOad)
(progn
(start_list "listbox" 3)
(mapcar 'add_list Listof)
(end_list)
(if Message
(set_tile "text1" Message)
)
(if (not Toggle)
(mode_tile "toggle1" 1)
)
(mode_tile "listbox" 2)
(action_tile "accept"
"(progn
(setq tmpStr (get_tile \"listbox\"))
(if Toggle
(setq tmpTog (get_tile \"toggle1\"))
)
(done_dialog 1)
)"
)
(action_tile "cancel" "(done_dialog 0)")
(if (= (start_dialog) 1)
(progn
(if tmpStr
(setq tmpList (read (strcat "(" tmpStr ")")))
)
(if (= tmpTog "1")
(cons T tmpList)
tmpList
)
)
)
)
)
)
« Last Edit: October 13, 2008, 02:14:28 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Arthur Gan

  • Guest
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #22 on: October 13, 2008, 02:26:15 PM »
I've copied the codes and run it successfully, it'll be good if the totals can be calculated and display in the last row, can enhance this program?
For the width and height, I made a wild guess and after several tries I got it right, you see I do not know Autolisp, did not write a single program...
And I'm amazed by the codings.. did you type every single letter?
I used Notepad and it is cumbersome to make sure the file type is All Files to save as .lsp and not getting easier to copy files into certain folders using Microsoft XP.
May I ask which text/program editor you used to code it?
Thank you very much for your contribution, it is most appreciated!

T.Willey

  • Needs a day job
  • Posts: 5251
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #23 on: October 13, 2008, 02:45:16 PM »
It could be done, but I don't have time now, real work has happened.   :|

I use Notepad++ to write my lisp code in.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #24 on: October 13, 2008, 03:00:28 PM »
Arthur,
You may type VLIDE at the command prompt to activate the LISP editor within ACAD.
Open your lisp in there. You will find are many features to help you edit & troubleshoot the lisp.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

fixo

  • Guest
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #25 on: October 14, 2008, 09:43:58 AM »
thanks for continuing, here's my sketch of the user interface..
let me know if you need explanation.
thanks!
Thank you mr. Picasso for the nice picture
Give this a try again

~'J'~


Arthur Gan

  • Guest
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #26 on: October 15, 2008, 12:43:18 PM »
Thanks for this version A2T-v3, tried but failed.. it prompts for sample_att_ext_table.dcl?
Is there a .dcl file needed?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #27 on: October 15, 2008, 02:36:21 PM »
The routine creates its own dcl files in the folder where the DWG is found.
It uses a full path so it should be able to find them again.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Arthur Gan

  • Guest
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #28 on: October 15, 2008, 03:16:58 PM »
Here's a screen dump of the error, it doesn't seem to able to find the .dcl file though I've included in the Support File search path (Settings/Support/Files...)
Can you please help identify the problem?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: BOM Utility to extract selective attributes from blocks with tabulation
« Reply #29 on: October 15, 2008, 04:09:34 PM »
Try this version.
It was finding the file but there was a bug in the DCL syntax.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.