PDA

View Full Version : Help creating lisp please



Sparkleblu_eyes742529
2017-01-27, 06:20 PM
New here, please bear with me...
I am looking to have a lisp command that takes attributes from dynamic blocks and put them into a BOM. I know I can do the dataextraction command but that takes too long (trying to cut company costs for CAD work) I came across a lisp from Lee Mac that in a way works how I am looking for. The only thing is trying to put a code in and where to put the code in the lisp to bring in attributes from any dynamic blocks.
I figured out how to add more columns and name the columns how I need them to be, just need a part in the code to bring the attributes I need from blocks and put them in the correct column. I have attached a test drawing with a few dynamic blocks if that helps anyone, the original code (bnum.lsp) and my few changes with adding the columns (BOM_5.lsp).

Seriously? over a hundred views but no replies... thanks everyone...

--AuBe--
2017-02-03, 07:32 AM
The lisp you chose to try to change to you purposes wont really work the way you want it to. The way the code is written you can invoke properties that are already defined in AutoCAD but wont easily (or possibly at all) be able to read properties that you define, al la Attributes.

Data Extraction doesn't take very long and can be copied from drawing to drawing or be used in templates.
You would probably be better off looking into making better use of the Data Extraction tools.

tom.haws
2017-02-05, 08:40 PM
That's a pretty big application. It's not clear exactly what part you are stuck on. What specific task are you having a hard time programming? Getting the attribute values? Saving them to the table? Organizing them on the way? I wrote http://constructionnotesmanager.com/, which does pretty much the same thing, but I haven't yet released the source code. There's a little animation on the page that shows what CNM does. Maybe that will help you discuss what you are stuck on.

Tom

BIG-AL
2017-02-12, 12:18 AM
Was some answers provided over at Cadtutor ? I may have posted something. Post here for any one else. This is for blocks you need a second defun for dynamic blocks see Lee-mac. Just check plain block or dynamic and run correct defun.



; dwg index to a table
; by Alan H NOV 2013
(defun AH:dwgindex (/ doc objtable ss1 lay ans ans2 plotabs ss1 tag2 tag3 list1 list2 curlayout colwidth numcolumns numrows INC rowheight )

(vl-load-com)
(setq curlayout (getvar "ctab"))
(if (= curlayout "Model")
(progn
(Alert "You need to be in a layout for this option")
(exit)
) ; end progn
) ; end if model
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq curspace (vla-get-paperspace doc))
(setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table: ")))

; read values from title blocks

(setq bname "DA1DRTXT")

(setq tag2 "DRG_NO") ;attribute tag name
(setq tag3 "WORKS_DESCRIPTION") ;attribute tag name

(setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 bname))))

(if (= ss1 nil) ; for tomkinson jobs
(progn
(setq bname "COGG_TITLE")
(setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 bname))))
)
)

(setq INC (sslength ss1))
(repeat INC
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (SETQ INC (- INC 1)) )) 'getattributes)
(if (= tag2 (strcase (vla-get-tagstring att)))
(progn
(setq ans (vla-get-textstring att))
(if (/= ans NIL)
(setq list1 (cons ans list1))
) ; if
); end progn
) ; end if
(if (= tag3 (strcase (vla-get-tagstring att)))
(progn
(setq ans2 (vla-get-textstring att))
(if (/= ans2 NIL)
(setq list2 (cons ans2 list2))
) ; end if
) ; end progn
) ; end if tag3

) ; end foreach

) ; end repeat
(setvar 'ctab curlayout)
(command "Zoom" "E")
(command "regen")


(reverse list1)
;(reverse list2)

; now do table
(setq numrows (+ 2 (sslength ss1)))
(setq numcolumns 2)
(setq rowheight 0.2)
(setq colwidth 150)
(setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth))
(vla-settext objtable 0 0 "DRAWING REGISTER")
(vla-settext objtable 1 0 "DRAWING NUMBER")
(vla-settext objtable 1 1 "DRAWING TITLE")

(SETQ X 0)
(SETQ Y 2)

(REPEAT (sslength ss1)
(vla-settext objtable Y 0 (NTH X LIST1))
(vla-settext objtable Y 1 (NTH X LIST2))
(vla-setrowheight objtable y 7)

(SETQ X (+ X 1))
(SETQ Y (+ Y 1))
)

(vla-setcolumnwidth objtable 0 55)
(vla-setcolumnwidth objtable 1 170)

(command "_zoom" "e")

); end AH defun

(AH:dwgindex)

(princ)